New Angular2 Router support in Ionic

In general the new router works. Things to note:

  • use “@angular/router”: “3.0.0-beta.2”
  • have a fallback route {
    path: ‘’,
    redirectTo: ‘/form/main’,
    pathMatch: ‘full’
    },
  • “ionic serve” does not support HTML5 urls (aka no-hash-bang) so you can force angular to use hashes ionicBootstrap(MyApp, [ APP_ROUTER_PROVIDERS, { provide: LocationStrategy, useClass: HashLocationStrategy }, …

BUT
Of course the ionic navigation does not support this (at least currently) so NavController becomes fairly useless. You either use routerLink/Router.navigate("[/somewhere]") or navigate with ionic without support for angular routes. Maybe one day.

No new ionic url router in rc.0 :confused:

This is a deal-breaker for most web apps. @mhartington does the absence of routing support in RC0 imply there’s no plan for support in 2.0.0?

Agree. This is a huge issue for a web project I’ve been working on. I’ve been telling my team that routing is coming. We’ve all been waiting and are beyond disappointed to see it’s still not implemented.

1 Like

Hey guys! Just need to chime in here quickly.

The router implementation is in the codebase, it was just not documented/user ready for this release.

We understand the frustration, and appreciate yall hanging in there.
As for it’s status, it’s code complete.
We have a few internal folks testing it out at the moment to make sure everything works as expected, and it will be in the next RC.

So long story short…

Router/Deep Linker is done. We’re doing testing before it gets released released. It will be documented in the next RC.

:beers:

6 Likes

We all are programmers and we understand the problems and the time problems for release a new router like this, we know also it is in beta so nothing is for sure.

The problem is some of us, as me, pushed a lot to introduce ionic2 in our company but we also need a url router to create a webapp. And some people as me has to take responsibility and must explain now to management why we are still not able to finish the app, as you know time is money and why we will missing christmas business for our product.

We know it is all in beta, but please don’t say in june it takes a few week (integrating angular2 router) and then after 2 months you say it takes again a few weeks (creating new router) and now after nearly other two months it is still not here.

You all do a incredible good work and we all love ionic2 and your team, but please share more of your road maps and if something will not happen as expected and communicated let us it know as soon as possible.

I hope my personal opinion is understood not wrong! :yum:

Thx you sincerely

1 Like

Thanks, Mike! I took a look at the code and it looks like a config object with a links array gets passed to IonicModule::forRoot, but I’m not clear on how to define a route/link. I see a link can have a name, component, and segment. Is the segment the same format as a path string I’d use in a route object in the angular2 router? I’m sure you have some docs on the way, but any guidance you could provide to help us get started with this would be great.

1 Like

I’ll be adding docs to this in the coming days, and “should” land in the nightly docs sooon.

7 Likes

Thank you for your hard and superb work.
Is there any documentation on how to use this yet? It will be very useful.

1 Like

@mhartington,

I noticed some documentation on http://ionicframework.com/docs/v2/api/navigation/DeepLinker/. I tried to implement it, but it’s not apparent how to get it to work. Is this the correct documentation? Any examples available?

Thanks!

Hi @mhartington,

What about lazy-loading? Is DeepLinker related to lazy-loading? The rc0 upgrading guide refer the angular ngModule page which also mentioned lazy loading. Do it means we can use angular router + lazy loading in ionic rc0? Can you guys provide a simple lazy loadnigrouter example/plunker ? We have a hard time to use lazy loading in rc0. Lazy loading is essential for our app, our app has 50+ pages.

Thanks a lot.

3 Likes

We too, we hope they release something as soon as possible. But they will clearly not support angular router

Is there going to be support for lazy loading in ionic 2? I’m starting a project at work and I can’t do it without the lazy loading. The bundle.js file will be gigantic. Is it something you are developing or is it not coming at all? Would be nice to have a straight answer.

2 Likes

Hey all,

After a bit of digging, I have routing working with data. It’s currently using hash location strategy, but I assume that would be straight forward to switch to path location strategy:

Not sure about the lazy loading at the moment.

Thanks,

D

Hi all,

Any update here on routing and documentation / tutorials? My app heavily relies on networking and routing which is in ionic 1. I really need to get a win and update here so that I can migrate. I’ve spent the last 2 days trying to work with deprecated libraries for some bits to find that I can’t even move yet to Ionic 2.

Love the platform, looking forward to moving to Ionic 2!

Thanks
Kieran

I’ll just leave this here…

http://ionicframework.com/docs/v2/api/navigation/DeepLinker/

4 Likes

Awesome Thanks Mike!

Best,
Kieran

Great work from ionic team, we are hoping and waiting for a blog or a video :slight_smile:

@referral.works
Did you already implement DeepLinker, does it do anything you need?

Would be great to see one of the sample apps updated to use DeepLinker. Running into some issues with my tabbed app, where I don’t have explicit calls to this.nav.push() to integrate with DeepLinker.

1 Like

Yeah it would be nice have a DeepLinker example App, or a blog about it.