title: AngularJs pass promise response as argument to function
body: <p>I ran into a small dilemma. In this angularJs app (1.3.7v) I fetch requirements as well as user belongings from the server and perform some front-end validation. Which looks something like this:</p>
  
  <pre><code>validationFunction = function(userId){
    return new Promise(function(resolve, reject){
      Promise.all([
        requirementService.requirementApi.requirements.getAll().$promise,
        userBelongingsService.userBelongingsApi.getAll(userId).$promise
      ]).then(function(requirements,belongings){
        console.log(requirements, belongings);
        resolve(isValid(requirements,  belongings));
      }).catch(function (err) {
        reject(err);
      });
    });
  }
  </code></pre>
  
  <p>For reference I also tried</p>
  
  <pre><code>validationFunction = function(userId){
    return new Promise(function(resolve, reject){
      requirementService.requirementApi.requirements.getAll().$promise.then(function(requirements) {
        return [requirements, userBelongingsService.userBelongingsApi.getAll(userId)];
      }).then(function(requirements,belongings){
        console.log(requirements, belongings);
        resolve(isValid(requirements,  belongings));
      }).catch(function (err) {
        reject(err);
      });
    });
  }
  </code></pre>
  
  <p>The promises are async and so they only get resolved later. But if used with .then() it should wait until they are resolved (rejected or resolved). Although in both methods the promises are resolve(at some time) at the moment when they are passed to the function they are not. And so the function fails saying that they are undefined. So what is the other way or am I missing something? :)</p>