javascript - Using Angular's $q.all with codependent promises -
second promise needs result of first promise parameter. have seen example of solving problem es6 promises.
firstthingasync() .then(function(result1) { return promise.all([promise.resolve(result1), secondthingasync(result1)]); }) .then(function(result1, result2) { // result1 , result2 }) .catch(function(err){ /* ... */ });
but not sure $q function has similar behavior promise.resolve. ideas?
in angular 1.4 can use $q.resolve(result1)
.
source: angular 1.4 $q.resolve docs.
in older versions can use $q.defer().resolve(result1)
.
source: angular 1.3 deferred api docs.
Comments
Post a Comment