下面是我的控制器代码,
app.controller('logoutCtrl', ['$scope', '$http','$window','$state',
function ($scope, $http,$window,$state) {
$scope.logout = function() {
console.log('inside logmeout');
delete $window.sessionStorage.token;
$state.go('access.login');
};
}]);
HTML
<li class="last" ng-controller="logoutCtrl">
<a href="" ng-click="logout()">
<i class="material-icons">lock</i> Logout
</a>
</li>
app.router.js
.state('access', {
url: '/access',
template: '<div ui-view class=""></div>'
})
.state('access.login', {
url: '/login',
templateUrl: 'partials/ui-login.html',
controller: 'LoginFormController',
resolve: {
deps: ['uiLoad',
function(uiLoad) {
return uiLoad.load(['scripts/controllers/login.js',
'../bower_components/font-awesome/css/font-awesome.css']);
}
]
}
})
单击注销时,我无法重定向到另一个状态('access.login')。控件进入 logout() 内部并且能够打印控制台消息并且正在删除令牌但重定向没有发生..我可以得到任何帮助..