title: AngularJS - wait for multiple resource queries to complete
body: <p>I have a single factory defined with ngResource:</p>
  
  <pre><code>App.factory('Account', function($resource) {
      return $resource('url', {}, {
          query: { method: 'GET' }
      });
  });
  </code></pre>
  
  <p>I am making multiple calls to the query method defined on this factory. The calls can happen asynchronously, but I need to wait for both calls to complete before continuing:</p>
  
  <pre><code>App.controller('AccountsCtrl', function ($scope, Account) {
      $scope.loadAccounts = function () {
          var billingAccounts = Account.query({ type: 'billing' });
          var shippingAccounts = Account.query({ type: 'shipping' });
  
          // wait for both calls to complete before returning
      };
  });
  </code></pre>
  
  <p>Is there a way to do this with AngularJS factories defined with ngResource, similar to jQuery's $.when().then() functionality? I would prefer not to add jQuery to my current project.</p>