javascript - Angularjs $http and progress bar -
i need upload file , use $http (this code .service() function):
sendfile: function (params) { return $http({method : 'post', url : 'http://xxxxxxxxxxxxx/rest/file.json', headers : { 'x-csrf-token' : $cookies['csrftoken']}, data : params }) },
now, little file , line there no problem, big file and/or bad/slow line there problem of ui: user can not know when upload end. need progress bar.
so have search on internet, have not found solution. there possibility progress/notification $http ?
i have tried code without luck:
profileservice.sendfile(data) .then(function(ret) { var uri = ret.data.uri; scope.content = "upload finished"; scope.postform.fid = ret.data.fid; scope.postform.buttondisabled = false; }, function(error) { scope.postform.showerror = true; scope.postform.errormsg = error.data; }, function(progress) { console.log("inside progress"); console.log(progress) } );
“progress” function never called.
i'm using angular 1.2.x
thanks.
you can use angular loading bar. works automatically $http
requests , not need setup except adding app dependency.
angular.module('app', ['angular-loading-bar']); // that's
Comments
Post a Comment