有州路线:
.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'];
当我打电话时,State Profile没有任何反应。但如果我改变决心:
resolve:
{
message: function (AuthService) {
return "Test resolve";
}
然后一切正常。为什么不起作用?
答案 0 :(得分:0)
我发现了问题。这是工作方式:
resolve:
{
AuthService: AuthService
}