AngularJS service not invoking error callback on save() method

前端 未结 6 2170
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 18:07

So I\'m using angularjs restful service $resource and I\'m calling $save function. However, the error callback I pass to it is not being called. The server is sending a 41

6条回答
  •  孤城傲影
    2021-01-17 18:54

    I had troubles with the error callback as well, but it appears that in more recent versions of AngularJS, the error callback method must now be implemented something like this:

    SomeResource.query({}, angular.noop, function(response){
      $scope.status = response.status; 
    });
    

    Source + more detailed description: https://groups.google.com/d/msg/angular/3Q-Ip95GViI/at8cF5LsMHwJ

    Also, in response to the comments on Flek's post, it seems that now only responses between 200 and 300 are not considered an error.

提交回复
热议问题