从历史记录中删除页面,因此“返回"会正常工作 [英] Remove page from history, so "back" will work properly
问题描述
我有我的应用程序,您需要登录才能进入其他页面.
I have my app that you need to login to get in to the other pages.
所以第一页是登录",它检查您是否已经登录,如果是,您将被重定向到主页面应用程序,如果没有,它将显示登录页面.
so the first page is "login" and it checks if you are already logged, if so you will be redirected to the main page app, if not it will show you the login page.
现在的问题是当用户在登录页面区域内时,他点击返回,他将进入登录"页面,然后重定向回主页面,因为他已经登录.
now the problem is when the user is inside the logged page area, and he clicks back he will get to the "login" page and than redirected back to the main page, as he is logged in already.
所以他陷入了无限循环.
So he is stuck in an infinite loop.
如何从历史记录中删除登录页面.
how can I remove the login page from the history.
就像在android中android从历史堆栈中删除活动"
just like in android "android remove activity from history stack"
推荐答案
这里是解决方案!
简单地使用:
$ionicHistory.nextViewOptions({
disableBack: true
});
登录功能示例:
$scope.login = function () {
Security.login($scope.cred.email, $scope.cred.password)
.success(function(data) {
Security.setUser(data.data[0]);
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('posts', {}, {location: "replace", reload: true});
}).error(function(data) {
$scope.showAlert();
});
};
这篇关于从历史记录中删除页面,因此“返回"会正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!