I am trying to get an Angular $q service descriptor and its associated objects and API. When I look at objects in the console, I see:
var deferred = $q.defer() ...(and then from console inspection)... $q: Object {defer: function, reject: function, when: function, all: function} deferred: Object {resolve: function, reject: function, notify: function, promise: Object} deferred.promise: Object {then: function, catch: function, finally: function}
There are several questions:
- What is the difference between
$q.reject() and deferred.reject() ? When to use each? - What is the relationship between
errorFn in deferred.promise.then(successFn, errorFn) and catchFn in deferred.promise.catch(catchFn) ? - If I have a bunch of nested promises and an error occurs, will the most external
catch() function always be called? What if one of the nested promises also has a catch function? Will this catch prevent the outermost catch from being fulfilled?
Thank.
javascript angularjs promise
lostdorje Jun 27 '14 at 4:02 2014-06-27 04:02
source share