title: Cannot get $q.all with nested promises working - wait for all
body: <p>I fully understand that similar questions have been asked before but I don't get it running. I need a chain of promises and I need to wait until all promises are resolved.</p>
  
  <p>My issue is that I need to call different promises based on the outcome of another promise :-(</p>
  
  <p>So based on the outcome of <strong>promise2</strong> my <strong>promise4</strong> is <strong>EITHER</strong> <em>$translate.use</em> <strong>OR</strong> it is <em>$translate.refresh</em>. </p>
  
  <p>This is what I have so far (simplified):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>      
        var promise1 = someService.get({}).$promise.then(function (result) {
           // do stuff
        });
  
        var promise2 = anotherService.getPromise().then(function (result) {
          var properties = result[0];
          // do stuff
          return properties;
        });
  
        var promise3 = promise2.then(function(properties){
  
          // using $translate (angular-translate) here which is async as well
  
          var userLanguage = properties.language;
          if (userLanguage !== $translate.preferredLanguage()) {
            // either this is the 4th promise
            $translate.use(userLanguage).then(function (myVar) {
              // ...
            });
          } else {
            // or this is the 4th promise
            $translate.refresh().then(function (myVar) {
              // ...
            });
          }
        });
  
        var loadPromises = {
          promise1: promise1
          promise2: promise2
          promise3: promise3
          promise4: ???
        };
  
        $q.all(loadPromises).then(function (result) {
          // anything done
        });</code></pre>
  </div>
  </div>
  </p>