In the documentation of Angular2 Router, Configuration section says
A router has no route definitions until we configure it. The preferred way to simultaneously create a router and add its routes is with a @RouteConfig decorator applied to the router's host component.
but in the example that follows it's using the @Routes
decorator instead of @RouteConfig
and in many examples i have seen use the @RouteConfig
and that confuses me because i'm not sure how this works...
@Routes([
{path: '/crisis-center', component: CrisisListComponent},
{path: '/heroes', component: HeroListComponent},
{path: '/hero/:id', component: HeroDetailComponent}
])
Note: I'm trying to use the release candidate version of angular2
Update
I managed to write an example and make it work using the new decorator @Routes
.
Plnkr Preview: Angular2 + Routing + Typescript + materialize-css
Plnker Code: Angular2 + Routing + Typescript + materialize-css