无法从离子注销 [英] can't logout from ionic
本文介绍了无法从离子注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了 ionic 登录和注销的问题.
Hi I have an issue with ionic login and logout.
每次注销后,我仍然可以单击后退按钮,它会将我带回上一页.我可以知道如何在注销时清除或删除会话,以便用户无法从登录返回上一页吗?
Each time after logout, i can still click the back button and it will bring me back to my previous page. may i know how to clear or delete session when logout so that user unable to go back to previous page from the login?
var default_stat;
$scope.logout = function(){
$ionicLoading.show({template:'Logging out....'});
$localstorage.set('loggin_state', '');
$state.go('login');
$ionicLoading.hide();
$ionicHistory.clearHistory();
$ionicHistory.clearCache();
};
在登录时我使用 localstorage 来表示用户已经登录
during login i use localstorage to indicate user has logged in
$localstorage.set('loggin_state', '1');
推荐答案
我会这样做:
$scope.logout = function(){
$ionicLoading.show({template:'Logging out....'});
$localstorage.set('loggin_state', '');
$timeout(function () {
$ionicLoading.hide();
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
$ionicHistory.nextViewOptions({ disableBack: true, historyRoot: true });
$state.go('login');
}, 30);
};
我发现添加一点延迟可以让 $ionicHistory
清除缓存.
I've found out that adding a little delay allow $ionicHistory
to clear the cache.
$ionicHistory.nextViewOptions({ disableBack: true, historyRoot: true });
- disableBack:下一个视图应该忘记它的后视图,并将其设置为空.
- historyRoot:下一个视图应该成为其历史堆栈中的根视图.
- disableBack: The next view should forget its back view, and set it to null.
- historyRoot: The next view should become the root view in its history stack.
这篇关于无法从离子注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文