Angular 2 root's route is always active

后端 未结 3 1886
星月不相逢
星月不相逢 2021-02-20 07:45

Recently I read this useful article about Angular 2 Router and looked at the demo. Everything seemed to be perfect. But when I tried to determine the active route based on

3条回答
  •  天命终不由人
    2021-02-20 08:39

    Its not a bug to my knowledge, you need to have a fallback component for / or unknown paths. (most likely HomeComponent)

    @Routes([
      { path: '/home', component: HomeComponent },
      { path: '/about', component: AboutComponent },
      { path: '*', name: component: HomeComponent }
    ]);
    

    This though is using the new Router module (not the deprecated one) and works in rc.0 and rc.1

提交回复
热议问题