如何使用带有angularjs 1 http请求的eventHandlers和uploadEvntHandlers?

我试过这段代码没有成功
$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对象.

不要使用onprogress,只使用进度,与其他事件一样.我准备一个 plunkr来演示:
$http({
      method: "GET",url: "data.json",eventHandlers: {
        progress: function(event) {
          console.log("progress");
          console.log(event);
        },readystatechange: function(event) {
          console.log("change");
          console.log(event);
        }
      },uploadEventHandlers: {
        progress: function(object) {
          console.log(object);
        }
      }
    })
    .success(function(json) { // succès
      $scope.lemmes = json;
      //console.log($http);
    }).error(function(error) { // erreur
      console.log(error);
    });

此外,还有一个错误已在角度1.5.5中修复,因为它可以从CHANGELOG中看到.更新到1.5.5或更高版本它将起作用.

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...