2016-04-23 89 views
1

有無狀態路線:角JS不工作的決心

.state('stateProfile', { 
     url: '/Profile', 
     views: { 
      "ContentContainer": { 
       templateUrl: '/Navigation/Profile', 
       controller: AuthController, 
       resolve: { 
        message: function (AuthService) { 
         return AuthService.GetMessage(); 
        } 
       } 
      } 

這是我的服務:

var AuthService = function ($timeout, $q, $location) { 
return{ 

    GetMessage : function() { 
     return "Hello"; 
     } 
} 
}; 
AuthService.$inject = ['$timeout', '$q', '$location']; 

控制器:

var AuthController = function (message, $q, $location, $timeout) { 
console.log('auth work'); 
console.log(message); 
}; 

AuthController.$inject = ['message', '$q', '$location', '$timeout']; 

當我打電話,什麼都不會發生國家檔案。但如果我改變我的決心:

resolve: 
{ 
     message: function (AuthService) { 
     return "Test resolve"; 
} 

然後一切正常。爲什麼它不起作用?

回答

0

我發現了這個問題。這是工作的方式:

resolve: 
{ 
    AuthService: AuthService 
}