I'm new to this promises world and I got quite a situation I don't know what to do.
I have a new promise been called by the result of the first promise.
Here is the situation:
function asyncCall(object){
return firstObject.loadSomething(object).then(function(result) {
result.innerAsyncCall().then(function() {
finalCode();
});
});
}
I loop over asyncCall and build a $q.all().then() to wait for the promises to resolve.
However, since the inner promise is not chained it runs independently.
Sample Code:
var promises = [];
array.forEach(function(object){
promises.push(asyncCall(object));
});
$q.all(promises).then(function(){
console.log('Done!!');
});
The question is. What can I do to wait the full execution of the inner promise?