javascript - Reject a chained promise -
the angular docs say chain promises, this:
promiseb = promisea.then(function(result) { homecoming result + 1; }); is possible reject promiseb within function?
promiseb = promisea.then(function(result) { if (result > 0) { homecoming result + 1; } else { // reject promiseb } }); p.s.: in illustration assume promisea resolves.
promiseb = promisea.then(function(result) { if (result > 0) { homecoming result + 1; } else { homecoming $q.reject('whatever reason'); } });
this works sine homecoming value of success callback of promisea gets converted promise either resolved homecoming value of success callback or rejected if explicitly reject $q.reject or throw exception.
javascript angularjs q
No comments:
Post a Comment