Reputation: 1517
I'm searching the web to find a solution to implement url routing in Ionic2, I can't seem to find a way to access a page using a URL.
I need to be able to get the physical url of a page within the web app; in order to be able to share it outside the web app.
Thank you,
Upvotes: 3
Views: 4694
Reputation: 544
I think you are looking for the Ionic service DeepLinker. That does not replace the FILO/NavController but provide a way to define and display specific views based on URLs.
In your main module add:
imports: [
IonicModule.forRoot(MyApp, {}, {
links: [
{ component: DetailPage, name: 'Detail', segment: 'detail/:userId' }
]
})
]
Also, if you also release your PWA on the AppStore/Play Store, you can use the native plugin Ionic Deeplinks.
Upvotes: 7
Reputation: 6421
Ionic 2 uses a pile FILO schema for routing with his NavController methods ( like push
, pop
, setRoot
). And you don't need to use a sequence for it like you would do with a Routing system, like to access page 2 i need to go through page 0 and 1, you can just push(NewPage)
and it will work, so it gives you a much better control over your application pages and how they interact.
I've never seen anyone talking about using it. If the NavController uses the Angular 2 routing in its background i don't know, will search for this, but the Ionic NavController is easy to use and works very good on most cases, the only case it doesn't support yet is passing parameters back within his pop()
method, for this i use a modal and style it totally like a normal page. You can also use setRoot
instead of pop
to pass data like so.
this.navCtrl.setRoot(MyPage, this.Data);
For more information please see the ionic 2 documentation on navigation
Upvotes: 0