I am upgrading my application progressively using the Upgrade Adapter. My app uses ui-router (+ has child routes).
I read this great article about routing in Angular 2. My question is:
Is it possible to use new router while still in Angular 1.X app + Upgrade adapter?
For example:
I have an angular 1.X template with <div ui-view=""></div>
. When I upgrade it to be Angular 2.0 component I must use the new component router with it, because Angular 2.0 is rendering this component now. But, in order to use it I should do:
bootstrap(App, [provide(LocationStrategy, { useClass: PathLocationStrategy })])
Which I do not have when bootstraping with the Upgrade Adater!
Should I first move the bootstrap to be Angular 2 and only then move to the Component router?
Thanks
Yes you can as said by @tomer above. i want to add some point to @tomer answer. firstly you need to provide name to the router-outlet where you want to load the second routing view in your view.
Import RouterModule from @angular/router link To add this functionality to your sample application, you need to update the app. module. ts file to use the module, RouterModule . You import this module from @angular/router .
You could use location.go(url) which will basically change your url, without change in route of application.
Absolutely! Your component containing ui-view
should be changed to a router-outlet
, but otherwise, you should be able to convert your routes to AngularJS components and use them with the new RouterModule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With