New Angular2 router configuration

后端 未结 3 974
迷失自我
迷失自我 2020-12-01 15:21

Back when using the deprecated router I was able to do a router.config and pass in an object. Thing is, the router itself got configured a bit after the app was started, the

3条回答
  •  一向
    一向 (楼主)
    2020-12-01 16:12

    In fact, in short you need to use @Routes instead of @RouterConfig. Here is a sample:

    @Routes([
      {path: '/crisis-center', component: CrisisListComponent},
      {path: '/heroes',        component: HeroListComponent},
      {path: '*',        component: CrisisListComponent}
    ])
    export class AppComponent { }
    

    See this doc on angular.io for more details:

    • https://angular.io/docs/ts/latest/guide/router.html

    You can notice that it remains some typos in this doc since this chapter is a work in progress ;-)

提交回复
热议问题