title: Angular-UI Router - Resolve not waiting for promise to resolve?
body: <p>So to summarise I am using angular-ui router resolve function to retrieve state specific data. However it doesn't seem to full wait for the promise to resolve:</p>
  
  <pre><code>state('parent.ChildState', {
                  url: '/myUrl?param1&amp;param1',
                  templateUrl: 'views/list.view.html',
                  controller: 'MyController',
                  resolve: {
                      data: resolveData
                  }
              }).
  
      function resolveData($stateParams, Utils) {
          var filters = Utils.getFilters($stateParams);
  
          DataService.myDataObj = DataService.get(filters, function(result, headers) {
              DataService.myDataObj = result;
          });
          return DataService.myDataObj;
  
          // Note I have also tried returning directly the DataService.get call however this makes all the below console log statements as undefined (see below for the controller code to know what I mean). So I do the assignment first and then return that.
      }
  </code></pre>
  
  <p>Now in the controller I had a function that executes on load like so:</p>
  
  <pre><code>    function ExpensesController(DataService) {
  
          $scope.viewData = DataService;
  
          initData();
  
          function initData() {
              // this generally logs a ngResource and shows the full data obj on console
              console.log($scope.viewData.myDataObj);
  
             // this gets undefined on console
             console.log($scope.viewData.myDataObj.someField1); 
  
             // this log fine, however why do I need to do promise      
             // resolve? should be resolved already right?
             $scope.viewData.myDataObj.$promise.then(function() {
                 console.log($scope.viewData.myDataObj.someField1);
             });
  </code></pre>