title: $q.defer vs new promise(function (resolve, reject))
body: <p>I have this html:</p>
  
  <pre><code>&lt;div class="documentation-comment-view h100" ng-if="views.comment.selected"&gt;
      &lt;div ng-include="views.comment.templateUrl" class="h100"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="documentation-annotation-view h100" ng-if="views.annotation.selected"&gt;
      &lt;div ng-include="views.annotation.templateUrl" class="h100"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="documentation-localisation-view h100" ng-if="views.localization.selected"&gt;
      &lt;div ng-include="views.localization.templateUrl" class="h100"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The html content is changing depending of the value of a variable.</p>
  
  <p>This is a part of the code in charge of it:</p>
  
  <pre><code>            myService.myFunction(param).then(function (retData) {
  
                  //Do something here...
  
                  changeView(scope.views.comment);
              });
  </code></pre>
  
  <p>And my problem is with promises and these two functions what are suppose to do the same:</p>
  
  <p>Function1:</p>
  
  <pre><code>    function myFunction(param) {
          var deferred = $q.defer();
  
          //Do something...
          deferred.resolve(retData);
  
          return deferred.promise;
      }
  </code></pre>
  
  <p>Function 2:</p>
  
  <pre><code>    function myFunction(param) {
          return new Promise(function (resolve, reject) {
  
              //Do something...
  
              resolve(retData);
  
          });
      }
  </code></pre>
  
  <p>Using any of both functions I don't get any errors and changeView is reached in both. But for any reason, the view is not changed using function 2. It works only using function 1.</p>
  
  <p>Any help finding a reason why this happens? Thanks.</p>