You use $q.all
to get a promise whose .then
unwraps both of them:
var images = $http.get('images.json');
var fruits = $resource('fruits.json').get().$promise;
$q.all([images,fruits]).then(function(results){
var images = results[0];
var fruits = results[1];
// access to both here, you can compare anything you want
});
The guide for $q.all
says:
Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
In other promise libraries like Bluebird and in ES6 promises, thatr functionality would probably be Promise.all
, in the original Q it's Q.all
.