In jQuery we can do
$.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) ).done(function( a1, a2 ) {
...
});
What's the equivalent in angular? I really need to wait for all ajax calls finish then do stuff. Thanks.
Asked
Active
Viewed 1,226 times
2 Answers
4
You can use $q.all
to handle multiple promises. Also, use $http to make the calls, that's more angular.
Here is a nice tutorial:
https://egghead.io/lessons/angularjs-q-all
Hope that helps.

Fedaykin
- 4,482
- 3
- 22
- 32
3
The equivalent would be:
$q.all([$http.get('/page1.php'),$http.get('/page2.php')]).then(function(values){
var a1 = values[0];
var a2 = values[1];
...
});

Michael Kang
- 52,003
- 16
- 103
- 135