Quick Tip: Navigating in Ionic without History
A quick tutorial on how to move a user logging in to a new state with the Ionic framework.
Join the DZone community and get the full member experience.
Join For Freebefore i start, just a quick note. what i’m describing here is clearly documented , but as i keep reminding myself i’ve yet to read 100% of the ionic docs and i really need to. a big thank you goes out to @breakingthings on the ionic worldwide slack channel for letting me know about this. so here’s the question. imagine you have an ionic app with a login screen:
after logging in, you want to automatically move the user to a new state:
$state.go('home');
but when you do, you end up with this in your header:
that link back to the login view comes from how ionic handles view history and the header. most of the time you probably want that, but in this case, i definitely do not want it. luckily it is rather simple to fix using $ionichistory :
$ionichistory.nextviewoptions({
disableback: true
});
$state.go('home');
yep, that’s it. nice and simple. and just in case it isn’t clear, this modification only impacts the next change.
Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments