【发布时间】:2016-10-28 11:37:43
【问题描述】:
我试过这段代码没有成功
$http({
method:"GET",
url:"data/mycooljsonfile.json",
eventHandlers:{
onprogress:function(event){
console.log("progress");
console.log(event);
},onreadystatechange:function(event){
console.log("change");
console.log(event);
}
},
uploadEventHandlers:{
onprogress:function(object){
console.log(object);
}
}
})
.success(function(json){ // succès
$scope.lemmes=json;
//console.log($http);
}).error(function(error){ // erreur
console.log(error);
});
我在这里检查过:
https://docs.angularjs.org/api/ng/service/$http
还有:
https://www.w3.org/TR/XMLHttpRequest/#events
只是我想改进我的代码,在将大 json 文件下载到应用程序时使用进度条。
顺便说一句,我找不到记录整个 $http 对象的功能和支持的事件的方法,因为它返回了一个包含少量信息的 promise 对象。
【问题讨论】:
-
我知道可以用纯 javascript 来做,我的问题是关于使用 Angular JS 版本 1,它在标题中。
-
现在在这个问题上摸索了几天。没有触发事件:(
-
德拉特。找到了解决方案。更新到 angularjs 1.5.5 :D
-
太好了,如果可以的话,希望我能参与到文档中。 @SSR 我可以有一个用例的链接吗?
标签: angularjs http xmlhttprequest