0

I opened link : Change bootstrap progress-bar width from angularjs

I'm trying to show progress-bar with percent while uploading the file, it should show actual uploading time in AngularJS.

Community
  • 1
  • 1
Ashish
  • 1
  • 1

1 Answers1

0

forget jQuery - it doesn't always play nicely with Angular since jQuery may update the DOM outside the Angular domain and then you have to start worrying about binding data to the view (which is done naturally with angular modules).

I recommend using ng-file-upload which provides progress information during upload.

I would also recommend using ui-bootstrap which has a nice progress bar to use. Just update the progress bar % info with the information given to you by ng-file-upload.

Hope this helps. Heres how to get % progress

$scope.upload = function (file) {
    Upload.upload({
        url: 'upload/url',
        data: {file: file, 'username': $scope.username}
    }).then(function (resp) {
        console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
    }, function (resp) {
        console.log('Error status: ' + resp.status);
    }, function (evt) {
        var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
        console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
    });
    };
danday74
  • 52,471
  • 49
  • 232
  • 283
  • Is image-select and ng-file-upload same in angularJS ? if not please suggest more in ng-file-upload in angularJS – Ashish Feb 05 '16 at 12:51
  • ng-file-upload allows the upload of multiple files - they can be image files ... see the docs at https://github.com/danialfarid/ng-file-upload – danday74 Feb 05 '16 at 12:58
  • not finding clear view about upload file with real time progress bar in angularJS – Ashish Feb 05 '16 at 14:02
  • Actually I have controller in angular, here i'm not able to get uploaded file size and remaining file size to upload. If have these both, then I'm able to find percent for progress-bar. here in jquery (evt or event ) is not working – Ashish Feb 05 '16 at 14:05
  • yes with jquery you will have binding difficulty - use ng-file-upload - i have added the code you need to my answer – danday74 Feb 05 '16 at 15:03
  • I downloaded above zip file, in separate, this application running fine. There are a lot of js and css files used in above. But I have to plug-in in my existing project. what specific file I need to add in plug-in in my existing application – Ashish Feb 08 '16 at 07:33
  • In above coding "evt" throwing exeption – Ashish Feb 08 '16 at 11:34
  • what is value of evt? is it ever 0? divide by zero is error - you need to do an IF statement to make sure it is not 0 – danday74 Feb 08 '16 at 11:59
  • saying "evt" is not defined and conflict with angular.js – Ashish Feb 09 '16 at 08:07