我根本无法看到问题,这是我的代码。
var app = angular.module('application', ['ui.router', 'ngResource','user.controllers','user.services']);
app.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider.state('home', {
url: '',
templateUrl: 'views/home.html'
}).state('account', {
url: '/account',
templateUrl: 'views/user/account.html',
controller: 'UserCtrl'
}).state('login', {
url: '/login',
templateUrl: 'views/user/login.html',
controller: 'UserCtrl'
}).state('logout', {
url: '/logout',
templateUrl: 'views/user/logout.html',
controller: 'UserCtrl'
}).state('register', {
url: '/register',
templateUrl: 'views/user/register.html',
controller: 'UserCtrl'
});
});
app.run(function ($rootScope, $state) {
$rootScope.$on("$stateChangeStart", function (event, toState, toParams, fromState, fromParams) {
console.log('toState.name: ' + toState.name);
console.log('fromState.name: ' + fromState.name)
});
});
这似乎很简单,但它不起作用。我确定这是一件我不了解Angular的小事,所以任何帮助都会受到赞赏。
谢谢!