In jQuery we can do $.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) ).done(function( a1, a2 ) { ... }); What is equivalent in angular? I really need to wait for all ahax calls to finish, and then do something. Thank.
$.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) ).done(function( a1, a2 ) { ... });
You can use $q.allto handle multiple promises. Also, use $ http to make calls, more angular.
$q.all
Here is a good tutorial:
https://egghead.io/lessons/angularjs-q-all
Hope this helps.
Equivalent:
$q.all([$http.get('/page1.php'),$http.get('/page2.php')]).then(function(values){ var a1 = values[0]; var a2 = values[1]; ... });
AngularJS documentation for $ q