How can I ensure that the complete()
function will run regardless of the outcome of the $http call using the promise API provided with Angular.js?
$
It depends on what you would like to do, but for clean-up logic and similar you may also use finally() to run either on fulfillment or rejection of your promise:
promise.finally(function () {
// Do something regardless of outcome.
});
Please note that although finally()
is supported by $q
(and some other libraries) is not part of the official draft.