1

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

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
CodeArtist
  • 5,534
  • 8
  • 40
  • 65

1 Answers1

3

The Angular team released RC1 with a totally new routing system. In beta versions of Angular2, routing was configured using @RouteConfig. In RC.1, this has been changed to @Routes. You can access the beta router by importing from @angular/router-deprecated instead of @angular/router

The Head Rush
  • 3,157
  • 2
  • 25
  • 45
  • do you have any example? Thanks – CodeArtist May 25 '16 at 16:32
  • There's an example using `@angular/router-deprecated` in the routing tutorial at https://angular.io/docs/ts/latest/tutorial/toh-pt5.html. Depending on your project, there may be some imports that don't resolve by switching to `router-deprecated`. If so, search the `@angular` folder in `node_modules` for the missing class. Migrating from beta to RC.1 was very much a trial and error process. – The Head Rush May 25 '16 at 16:41