Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Quick Tip: Navigating in Ionic without History

DZone's Guide to

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.

· Mobile Zone
Free Resource

Before 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:

iOS Simulator Screen Shot Jul 14, 2015, 12.58.55 PM

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:

shot2

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.

Topics:
ionic ,javascript

Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}