title: AngularJS - View gets undefined data from StateProvider
body: <p>I'm trying to send an object to my <code>view</code> from the <code>stateProvider</code> in my <code>AngularJS</code> application. The <code>state</code> does resolve the object and sends it, however in the view the object is suddenly <code>undefined</code>. How can this be?</p>
  
  <p><strong>StateProvider</strong></p>
  
  <pre><code> ...
   .state('view', {
          url: '/view/:view',
          templateUrl: urlBase + 'views/view.html',
          controller: 'viewController',
          resolve: {
              view: function ($stateParams, sharedProperties) {
                  sharedProperties.getConfig(sharedProperties)
                      .then(function(response){
                          var config = response.data;
  
                          console.log('config :', config);
  
                          for (var i = 0; i &lt; config.views.length; i++) {
                              if (config.views[i].route === $stateParams.view) {
                                  console.log('jackpot : ', config.views[i]);
                                  return config.views[i];
                              }
                          }
  
                          return undefined;
                      })
                      .catch(function(error){
                          console.log('Error : ', error);
                          return undefined;
                      });
              }
          }
      })
  ...
  </code></pre>
  
  <p><br></p>
  
  <p><strong>view</strong></p>
  
  <pre><code>angular.module('app')
  .controller('viewController', ['$scope', '$state', '$interval', '$window', 'view', 'socketService', 'userService', 
    function ($scope, $state, $interval, $window, view, socketService, userService) {
      console.log('view : ', view);
  
      var user = userService.get();
  
      //  If there is no view, return to login page
      if (view === undefined) {
          $state.go('welcome');
      }
  
      /*
       *  Sets the models to be used in the view
       */
      $scope.values = view.values;
  ...
  </code></pre>
  
  <p><br></p>
  
  <p><strong>shareProperties service</strong></p>
  
  <pre><code>app.factory('sharedProperties', function ($http) {
      var service = {};
  
      service.getConfig = function () {
          return $http.get('config.json');
      };
  
      return service;
  });
  </code></pre>
  
  <p><br></p>
  
  <p><strong>Console log</strong></p>
  
  <pre><code>config : Object {socketAddress: "ws://localhost:8081/Common",   IISProjectName: "simplanner", views: Array[1]} core.js:67
  jackpot :  Object {route: "Arbejds Tider", viewFunctions: Object, storedProcedure: Object, values: Array[5]} view.controller.js:3
  view : undefined
  
  angular.min.js:107 TypeError: Cannot read property 'values' of undefined
      at new &lt;anonymous&gt; (http://localhost:8080/simplanner/scripts/controllers/view.controller.js:15:29)
      at e (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:39:193)
      at Object.instantiate (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:39:310)
      at http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:80:313
      at http://localhost:8080/simplanner/lib/Angular-1.4.7/angular-ui-router.min.js:7:28006
      at aa (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:73:90)
      at K (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:62:39)
      at g (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:54:410)
      at http://localhost:8080/simplanner/lib/Angular-1.4.7/angular.min.js:53:480
      at k (http://localhost:8080/simplanner/lib/Angular-1.4.7/angular-ui-router.min.js:7:27219) &lt;div ui-view="" class="ng-scope"&gt;
  (anonymous function) @ angular.min.js:107
  (anonymous function) @ angular.min.js:80
  aa @ angular.min.js:73
  K @ angular.min.js:62
  g @ angular.min.js:54
  (anonymous function) @ angular.min.js:53
  k @ angular-ui-router.min.js:7
  (anonymous function) @ angular-ui-router.min.js:7
  n.$broadcast @ angular.min.js:136
  y.transition.M.then.y.transition.y.transition @ angular-ui-router.min.js:7
  (anonymous function) @ angular.min.js:119
  n.$eval @ angular.min.js:133
  n.$digest @ angular.min.js:130
  n.$apply @ angular.min.js:133
  h @ angular.min.js:87
  K @ angular.min.js:91
  z.onload @ angular.min.js:93
  </code></pre>