AngularJS$state.go未重定向到其他页面
下面是我的控制器代码AngularJS$state.go未重定向到其他页面,angularjs,state.go,Angularjs,State.go,下面是我的控制器代码 app.controller('logoutCtrl', ['$scope', '$http','$window','$state', function ($scope, $http,$window,$state) { $scope.logout = function() { console.log('inside logmeout'); delete $window.sessionStorage.token;
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
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']);
}
]
}
})
.state('access'{
url:“/access”,
模板:“”
})
.state('access.login'{
url:“/login”,
templateUrl:'partials/ui login.html',
控制器:“LoginFormController”,
决心:{
部门:['uiLoad',
功能(uiLoad){
返回uiLoad.load(['scripts/controllers/login.js',
“../bower_components/font-awesome/css/font-awesome.css']);
}
]
}
})
单击注销时,我无法重定向到另一个状态(“access.login”)。
控件位于logout()内部,能够打印控制台消息,并且正在删除令牌,但重定向未发生。。
我可以得到任何帮助吗?在模块定义中,您需要将“ui.router”作为依赖项传递,以便在项目中使用Angular ui router: 例如角度模块('my_app'、['ionic'、'ui.router']) 这对我也很管用 $state.go('the-state-name-in-quotes'))
如果您的网页显示在视图中,请不要忘记在要显示网页的父页面中包含ui视图
<div ui-view>
<!-- Child page will appear here -->
</div>
显示路线内的状态
定义!张贴config@RNS:告诉我们路线configuration@RNS查看您的状态:Access。登录时将访问视为父状态,并将其作为子状态登录。尝试将访问定义为父状态,然后创建子状态acecss.login,或者仅将登录名设置为statename是否有一个运行块,用于检查$stateChangeStart?
<div ui-view>
<!-- Child page will appear here -->
</div>