0

I have a nested promises as follows. I am just writing the pseudo code to reflect my use case.

$scope.result="";
Promise1.then(function1(value1){
Promise2.then(function2(value2) {
forloop() {
Promise3.then(function3(value3){
   $scope.result += value3;
}//end of function3
}//end of forloop
}//end of function2
}//end of function1.

How can I get the value of "result" outside of the Promise1. Can you please guide me on this in order to get the value of "result" so that I can use it as part of another code which is after executing those promises.

Thank you all

regards sivakiran B

user1061216
  • 83
  • 2
  • 7

1 Answers1

0

You can use $q.all to resolve multiple promises.

$q.all([Promise1, Promise2, Promise3]).then(function(results) {

for(var i=results.length;i--;) {
  console.log(results[i]);
}

});

Raj
  • 321
  • 1
  • 4