AngularJS - wait for multiple resource queries to complete

前端 未结 3 1561
遥遥无期
遥遥无期 2020-11-29 17:57

I have a single factory defined with ngResource:

App.factory(\'Account\', function($resource) {
    return $resource(\'url\', {}, {
        query: { method:          


        
3条回答
  •  囚心锁ツ
    2020-11-29 18:04

    I think a better solution is:

    $q.all([
       Account.query({ type: 'billing' }).$promise,
       Account.query({ type: 'shipping' }).$promise
    ]).then(function(data) {
       var billingAccounts = data[0];
       var shippingAccounts = data[1];
    
       //TODO: something...
    });
    

提交回复
热议问题