私はついにAngular promiseエラー処理をダウンさせましたが、それは私には直感的でした。私は失敗のコールバックによってエラーが処理されると予想しましたが、代わりにキャッチを使用しなければなりませんでした。Angularでは、約束のエラーとキャッチ関数の概念の違いは何ですか?
なぜ私は失敗のコールバックではなく、キャッチが実行されているのか、概念的には分かりません。
SomeAsyncService.getData().then(function (result) {
// The call is successful.
// Code in this block throws an error.
}, function (error) {
// I expected to handle errors here.
});
最終的に働いていた何を:私が期待したもの
。
SomeAsyncService.getData().then(function (result) {
// The call is successful.
// Code in this block throws an error.
}).catch(function (error) {
// Where the error is actually caught.
});
約束の誤りを処理する適切な方法がある場合は、教えてください。 angularJS documentation for $qことで
最初のものはエラーをキャッチしない、もう一つはありません。 – Jason