本文介绍了如何使用$ http或$ resource在angularjs 1.5.5中使用eventHandlers和uploadEventHandlers跟踪进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! var uploadData =新的FormData(); uploadData.append('file',obj.lfFile); var fileData = angular.toJson({'FileName':obj.lfFile.name,'FileSize':obj.lfFile.size }); uploadData.append('fileData',fileData) $ http({方法:'POST', url:vm.uploadPath,标题:{'Content-Type':undefined,'UserID':vm.folder.UserID,'ComputerID':vm.folder.ComputerID,$ b $'KeepCopyInCloud' :vm.keepCopyInCloud,$ b $'OverWriteExistingFile':vm.overwriteExistingFile,'RootFileID':vm.folder.RootFileID,'FileName':obj.lfFile.name,' FileSize':obj.lfFile.size }, eventHandlers:{ progress:function(c){ console.log('Progress - >'+ c); console.log(c); } }, uploadEventHandlers:{ progress:function(e){ console.log('UploadProgress - >'+ e); console.log(e); } }, data:uploadData, transformRequest:angula r.identity })。success(function(data){ console.log(data); console.log(status); }); 这些事件并没有被解雇。我错过了什么? 参考资料 https://github.com/angular/angular.js/issues/14436 https://github.com/angular/angular.js/pull/11547 解决方案在发布查询后找到它。感觉愚蠢。我不得不更新在鲍尔的angularjs版本,以确保所有的依赖关系解析为角1.5.5及以上。 详细参考资料 I am trying to strictly adhere to angularjs code using $http or $resource to do file upload.var uploadData = new FormData();uploadData.append('file', obj.lfFile);var fileData = angular.toJson({ 'FileName': obj.lfFile.name, 'FileSize': obj.lfFile.size});uploadData.append('fileData', fileData)$http({ method: 'POST', url: vm.uploadPath, headers: { 'Content-Type': undefined, 'UserID': vm.folder.UserID, 'ComputerID': vm.folder.ComputerID, 'KeepCopyInCloud': vm.keepCopyInCloud, 'OverWriteExistingFile': vm.overwriteExistingFile, 'RootFileID': vm.folder.RootFileID, 'FileName': obj.lfFile.name, 'FileSize': obj.lfFile.size }, eventHandlers: { progress: function(c) { console.log('Progress -> ' + c); console.log(c); } }, uploadEventHandlers: { progress: function(e) { console.log('UploadProgress -> ' + e); console.log(e); } }, data: uploadData, transformRequest: angular.identity}).success(function(data) { console.log(data);}).error(function(data, status) { console.log(data); console.log(status);});The events are not fired at all . What am i missing ?Referenceshttps://github.com/angular/angular.js/issues/14436https://github.com/angular/angular.js/pull/11547 解决方案 Found it after posting the query. Feeling stupid. I had to update the angularjs version in bower to ensure all dependencies resolve to angular 1.5.5 and above.Reference for Details 这篇关于如何使用$ http或$ resource在angularjs 1.5.5中使用eventHandlers和uploadEventHandlers跟踪进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-06 14:53