0
我是新手,第一次在角度上工作。我正在調用一個角度的服務。當通話成功時,它會給我回復如用戶名和他的登錄信息。當呼叫失敗,它給了我錯誤消息。我得到的成功的響應我能夠綁定在HTML端但響應我失敗我無法綁定在HTML上可以指導我如何我可以綁定失敗對html的迴應。在此先感謝 這裏是我的功能,捕獲角js失敗的響應?
function getInsuredWebAccount(insuredId) {
var deferred = $q.defer();
var web = $resource(webAccountServiceHostName, {}, {
get: {
method: 'Get',
headers: {
Authorization: 'Basic c3J1bml0ZTo1OUJFODUwNUIyRjM0OEVGQTI1RTU1RjU4NEVGNUE0',
Accept: 'application/json;odata=verbose'
}
}
});
web.get({ insuredId: insuredId }, function onSuccess(response) {
var webInfo = response;
webInfo.a = webInfo.username;
if (moment(response.last_login_date).isValid()) {
response.last_login_date = moment(response.dateOfBirth).format('MM/DD/YYYY');
} else {
response.last_login_date = "";
}
deferred.resolve(response);
}, function onFailure(response) {
var info = response;
info.b = info.data.error_message;
deferred.reject(response);
});
return deferred.promise;
}