title: Chaining multiple promises created through for loop
body: <p>I have been studying promises through <a href="http://www.dwmkerr.com/promises-in-angularjs-the-definitive-guide/#advancedpromiseschaining" rel="nofollow">this link</a> and I understood the idea of it</p>
  
  <pre><code>var parentID;
  
  $http.get('/api/user/name')
    .then(function(response) {
  
    parentID = response.data['ID'];
    for (var i = 0; i &lt; response.data['event-types'].length; i++) {
      return $http.get('/api/security/' + response.data['event-types'][i]['key']);
    }
  
    })
    .then(function(response) {
  
      // response only returns one result of the many promises from the for loop
      // do something with parentID; 
  
    });
  </code></pre>
  
  <p>However, my use case requires to loop through and send create more than 1 promises. I have tried to chain an as example above but only the only one of the promise created from the for loop was executed. </p>
  
  <p>How can I continue chaining all of the promises while continue having access to the variable parentID?</p>