I have a login page that goes to another page once logged in. This new page has a back button to take you back to the login page which I don’t want. How do I clear the history so that this doesn’t happen?
http://ionicframework.com/docs/api/directive/navClear/
<a class="button button-positive" ng-click="login()" nav-clear>Login</a>
I’m having the same issue and clearing the nav history (either by invoking the clearHistory
function directly or adding the nav-clear
directive) doesn’t work - the next page still has a back button. I am using the sidebar layout and the $state.transitionTo
function to move from the login page to my main page on successful login.
Any ideas? (can post more code if it helps)
So that works if I put it in the <input type="submit" nav-clear>
and the user either clicks the submit button, or presses enter.
However, my login controller also checks to see if there are cached credentials from a previous login, and automatically tries to log the user in using that…and this is triggered in code. It is this case where the history isn’t cleared and the back button still appears.
Then you want something like this.
I studied that example for a while, and I don’t seem to see what part of that does what I want. I’m new to angularjs and ionic so many of the concepts here are new to me, so I appologize if this is a dumb question.
I did manage to get it to work another way, though I’m not sure if it’s a good way.
In my index.html I changed:
<body >
<ion-nav-view></ion-nav-view>
</body>
To:
<body >
<div ui-view></div>
</body>
And then I updated my login.html template to use <ion-pane>
instead of <ion-view>
So, now the login.html template doesn’t get added to the nav bar history…though I don’t know if this is a good way of solving this.