什么是jQuery.when()的角度相当于角度、jQuery、when

2023-09-10 19:26:00 作者:烈火中挣扎

在jQuery的,我们能做到 $。当($就(/page1.php),$就(/page2.php)).done(功能(A1,A2){   ... }); 什么是等值的角度?我真的需要等待所有的Ajax调用完成,然后做的东西。谢谢你。

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.

推荐答案

您可以使用 $ q.all 来处理多个承诺。此外,使用$ HTTP打的电话,这是更有棱角。

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

希望有所帮助。