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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

c# - MSDN OneNote Api: Navigate to never before opened page without opening a OneNote Application Window -