当触发statechangestart事件时,它将不会触发。 我使用角度v 1.7.3
app.run(function ($rootScope, $state, Auth, Access) {
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams, options){
var requireLogin = true;
if (requireLogin && typeof $rootScope.currentUser === 'undefined') {
event.preventDefault();
console.log(Access.isAuthenticated());
}
});
});