title: Angular forEach wait until all promises are complete?
body: <p>I'm doing a forEach loop and that makes an API call to Cloudinary, and I'm building an array with the response data.</p>
  
  <p>Once the data is collected, I need to send it to some other API.</p>
  
  <p>How do I wait on the promises getting resolved and the data collected before sending the data out?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>app.controller 'ProductImageUploaderController', ($upload, $routeParams, Product) -&gt;
  
    $routeParams.photos = []
  
    @startUpload = -&gt;
      @files.forEach (file) -&gt;
        upload = $upload.upload(
          url: 'https://api.cloudinary.com/v1_1/' + $.cloudinary.config().cloud_name + '/upload'
          fields:
            upload_preset: $.cloudinary.config().upload_preset
            tags: 'dev'
            folder: 'dev'
          file: file
        )
        upload.success (data) -&gt;
          $routeParams.photos.push(file)
  
      # Once the $routeParams.photos array is built, this is when I'd like to pass the data on.
  
    return
  </code></pre>