I am very familiar with how it works $q, and I use it in angularjs to wait for the only promises to be resolved, and several promises to solve using $q.all().
The question is, I'm not sure if this can be done (and if it works correctly): can I wait for the only promise for a solution, but then also run some code when all my promises will be resolved too ... AFTER successful completion callbacks for user promises ... for example:
var promises = [];
for(i=1, i<5, i++){
var singlePromise = SomeSevice.getData();
promises.push(singlePromise);
singlePromise.then(function(data){
console.log("This specific promise resolved");
});
}
$q.all(promises).then(function(data){
console.log("ALL PROMISES NOW RESOLVED");
});
My question is: does this work as it seems to me, or is there some strange asynchronous, vague result?