Reputation: 495
Second promise needs result of the first promise as a parameter. I have seen an example of solving this problem with ES6 promises.
firstThingAsync()
.then(function(result1) {
return Promise.all([Promise.resolve(result1), secondThingAsync(result1)]);
})
.then(function(result1, result2) {
// do something with result1 and result2
})
.catch(function(err){ /* ... */ });
But I am not sure what $q function has similar behavior to Promise.resolve. Any ideas?
Upvotes: 0
Views: 60
Reputation: 30340
In Angular 1.4 you can use $q.resolve(result1)
.
Source: Angular 1.4 $q.resolve docs.
In older versions you can use $q.defer().resolve(result1)
.
Source: Angular 1.3 Deferred API docs.
Upvotes: 1