how much is shared between Ionic’s Navigation component and Angular2’s Router?
Might be mistaking, It looks like Ionic implements it’s own separate Router.
I’m wondering if I can implement a global router with something resembling path-names.
It’s a bit painful to re-import all Page classes, re-implement the goToPage methods and therefore including circular dependencies.
Maybe I did not understand the docs, and I’m doing it wrong?
Hope someone can help! Thanks guys!
I am new here so forgive me if I am missing something.
Ionic builds its own “routing” so that developers can use the familiar stack approach to building pages. This allows you to push and pop pages and have ionic deal with all the animation and when to show the back button.
So the “correct” way to deal with routing it seems in ionic 2 is to have the NavController injected into your component and then use it to
push new views onto the stack.
If you are navigating between sections of your application and wish to not have a back button then you would use the
setRoot method on the navController to load up the new component.
As mentioned by @simbco, Ionic 2 doesn’t actually use a router, but instead uses a Navigation Stack. This is a slightly different paradigm way of thinking about navigation, but it is a popular pattern that is super simple and much easier to use than a router in many ways.
If you are setting up your app properly, you shouldn’t have to import ALL of your pages, only the ones you need to be able to navigate to from that component.
Thanks for clarifying guys! This makes a lot of sense!
I’ve worked around ways to reduce the number of imports e.g. sub-classing
One example were the auth pages that needed to have routing to: login page, register page, reset password page, etc…
Just added a simple AuthPage class with all the goTo functions once.