如何使用$ http或$ resource在angularjs 1.5.5中使用eventHandlers和uploadEventHandlers跟踪进度? [英] How to track progress using eventHandlers and uploadEventHandlers in angularjs 1.5.5 with $http or $resource?
本文介绍了如何使用$ http或$ resource在angularjs 1.5.5中使用eventHandlers和uploadEventHandlers跟踪进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
- < a href =https://github.com/angular/angular.js/pull/11547 =nofollow> 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 ?
References
解决方案
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.
这篇关于如何使用$ http或$ resource在angularjs 1.5.5中使用eventHandlers和uploadEventHandlers跟踪进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文