0
しかし、成功コールバックが良い働いている私は、エラーコールバック捕まえることができなかった私はangularJSでGETとPOSTリクエストを扱うサービスを作成しているが、問題は私のコントローラである:HTTPサービスキャッチエラー角度JS
app.js
AuthenticationService.Login(function (_data) {
$rootScope.showPreloader = false;
console.log(_data)//works fine when call is succes
},function (error){
console.log(error)//not executed when error is thrown
});
authentication.service.js
function Login(callback) {
$http({
method: "GET",
url: "/auth/getRoles",
headers: {
"Accept-Language": "en-US, en;q=0.8",
"Content-Type": "application/json;charset=UTF-8"
}
}).then(function (_response) {
return _response.data;
var serverData = response.data;
callback(serverData);//getting respone is controller when succes
}, _handleError);
};
function _handleError(_error) {
console.log(_error)//console prints on error
return _error//controller never recevies the return statement
};
問題は決して任意のヘルプは大幅に
http://blog.ninja-squad.com/2015/05/28/angularjs-promises/をお読みください。 –