ionic中登陆逻辑控制

问题

登陆成功后从login.html调转到home.html,此时在home页面按back键又回到了login.html 。

解决方案

登陆成功后,清除导航历史堆栈。

具体代码

menu.html

注销

controllers.js

.controller('AppCtrl', function ($scope) {
// 注销登陆
$scope.logout = function () {
// 清除缓存账号
window.localStorage.removeItem(cache.user);
}
}).
.controller('LoginCtrl',function($scope,$state,UserService){
UserService.login(data, function (response) {
//登陆成功
if (response.state == 1) {
// 跳转到首页
$state.go('home');
}
}
})
.controller('HomeCtrl',function($scope,$ionicHistory){
//在首页中清除导航历史退栈
$scope.$on('$ionicView.afterEnter', function () {
$ionicHistory.clearHistory();
});
});

posted @ 2016-07-22 17:59  Tonge  阅读(604)  评论(0)    收藏  举报