2016-11-16 34 views
-1

任何线索$ http的错误方法没有收到400个错误的请求?

$scope.submit = function (type) { 
     $http({ 
      method: 'GET', 
      url: '/example.com', 
      params: { 
      type: type.type 
      } 
     }) 
     .success(handleNewParameters) 
     .error(handleError); 
     }; 

这是一个老bug,我面对过一次。我应该重构所有我的成功和错误,然后方法?

+2

您在使用任何自定义拦截器?如果是这样,这是一个可能的重复http://stackoverflow.com/questions/27423983/angular-js-http-doesnt-catch-the-promise-error – JLRishe

+0

你在你的应用程序中使用拦截器? –

+0

另请参阅:http://www.jamessturtevant.com/posts/AngularJS-HTTP-Service-Success-Handler-400-Response-Code-and-Interceptors/ – JLRishe

回答

1

如果您已实现拦截,这时如果响应状态是400,你要转发的承诺..

因此,请确保您有这样的代码到底:

return $q.reject(rejection);