title: AngularJS - promise does not work with $route
body: <p>I'm trying to use promise with ngRoute. I've read about resolve but I'm not able to make it works. Template just gets promise object insteed of messages array. This is how it looks like:</p>
  
  <pre><code>angular.module('myModule', ['ngRoute'])
  
  .factory('MessageResolver', ['$q', '$timeout', function($q, $timeout)
  {                   
      var x = function()
      {                 
          var deferred = $q.defer();
  
          $timeout(function() 
          {
              deferred.resolve(['Hello', 'world!']);
          }, 2000);
  
          return deferred.promise;  
      }       
  
      return {
          getMessage : x
      }
  }])
  
  .controller('HelloCtrl', ['$scope', 'MessageResolver', function($scope, MessageResolver)
  {                      
      $scope.messages = MessageResolver.getMessage();
  }])
  .config(['$routeProvider', function($routeProvider) 
  {
      $routeProvider.when('/', 
      {
          templateUrl: 'index2.html', 
          controller: "HelloCtrl",
          resolve: ['MessageResolver']
      }); 
  }])  
  
  ; 
  </code></pre>
  
  <p>Thanks for any help.</p>