700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > angularJs 获取上传文件进度

angularJs 获取上传文件进度

时间:2020-04-19 12:51:16

相关推荐

angularJs 获取上传文件进度

angular在1.5.5以上的版本中,在$http中也加入了eventHandler和uploadEventHandlers等方法。

发送请求:

$http({method:"POST",url:basePath+"/roadShow/saveOrUpdate",eventHandlers: {progress: function(c) {console.log('Progress -> ' + c);console.log(c);}},uploadEventHandlers: {progress: function(e) {console.log('UploadProgress -> ' + e);console.log(e.loaded/e.total*100);}},data:form,headers:{"Content-Type":undefined},transformRequest: angular.identity})

其中,可以用e.loaded/e.total*100来计算进度:

实际应用时,可结合Math.floor()。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。