AngularJS: $q wait for all even when 1 rejected

后端 未结 8 1590
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 16:23

I\'ve been trying to wait for a couple of promises with Angular\'s $q but there seems to be no option to \'wait for all even when a promis is rejected\'. I\'ve created an exampl

8条回答
  •  星月不相逢
    2021-02-01 16:57

    The promise API in angularJS is based on https://github.com/kriskowal/q. I looked at API that Q provides and it had a method allSettled, but this method has not been exposed over the port that AngularJS uses. This is form the documentation

    The all function returns a promise for an array of values. When this promise is fulfilled, the array contains the fulfillment values of the original promises, in the same order as those promises. If one of the given promises is rejected, the returned promise is immediately rejected, not waiting for the rest of the batch. If you want to wait for all of the promises to either be fulfilled or rejected, you can use allSettled.

提交回复
热议问题