2016-11-16 33 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);