简体   繁体   中英

how to upload the image into azure storage blob using angualr2 and typescript

I am developing angular 2 application using typescript. in my current project I implemented the functionality for uploading image into storage blob, for that I followed the below link.

http://www.ojdevelops.com/2016/05/end-to-end-image-upload-with-azure.html

The above blog contains the code for angular 1 with javascript but I want the code for angular 2 with typescript.

app.controller('UploadCtrl', ['$scope', 'Upload', function ($scope, Upload) {
$scope.submit = function() {
    if ($scope.form.file.$valid && $scope.file) {
        $scope.upload($scope.file);
    }
};

$scope.upload = function (file) {
    Upload.upload({
        url: 'image/upload',
        data: { file: file }
    }).then(function (resp) {
        console.log('Success');
    }, function (resp) {
        console.log('Error');
    }, function (evt) {
        var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
        console.log('progress: ' + progressPercentage + '%');
    });
};

}]);

Can you please tell me how to convert the above lines of code into angular 2 using typescript.

Finally, I achieved the above functionality. for that the answer is available in the below link.

Upload the image into storage blob using typescript and angular2

-Pradeep

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM