Reputation: 1945
I just started learning angular2, and finished the hero tutorial. I have a few questions in regards to routing.
Is AppComponent supposed to be mainly used for the RouteConfig, and the initial selector? Is it better to extract the router out of AppComponent? is @angular/router-deprecated actually deprecated..?
Upvotes: 2
Views: 3519
Reputation: 8165
There's an official style guide which covers best practices. You might find your answer there.
From my point of view, it makes totally sense to declare the RouteConfig
in the component which handles the routing for you in its view (meaning implementing <router-outlet>
in your template).
If you take a look at some of the widely used angular2 seeds, you will most likely find a main.ts
or bootstrap.ts
which handles, well..bootstrapping of your app. It sets up fundamental providers and defines an entry point, which in most cases will be your app.component
. Now if in your case this "entry point" does something else before or after you want to setup your route configuration (and with this a template which has router-outlet
and probably some navigation stuff) you could seperate it of course, but in most cases that's the main purpose of this component.
And about the router-deprecated
package: yes it's "actually" deprecated (why would they call it this way otherwise? ;)).
But since the new package is not feature complete and is missing some stuff you might not want to miss, they offer support for the "old" router.
Upvotes: 3