儿童路线角2

时间:2017-02-01 11:22:18

标签: angular routing

我正在尝试路由到LocationComponent。好吧,我想让Locationcomponent成为Foodcomponent的子项,所以url就像“localhost:4200 / admin / food / location。我怎么做到这一点?谢谢

export const PanelRoutes: Routes =[

  {
    path: 'admin',

    component: AdminPanelComponent,
    children: [
      {path: '', redirectTo: 'game'},
      {path: 'game', component: GameComponent},
      {path: 'food', component: FoodComponent},
      {path: 'location', component: LocationComponent},

    ];


  }
];

@NgModule({
    declarations: [

        AppComponent,
        ...DashboardComponentList

1 个答案:

答案 0 :(得分:2)

试试这个:

{
  path: 'admin',
  component: AdminPanelComponent,
  children: [
    {path: '', redirectTo: 'game'},
    {path: 'game', component: GameComponent},
    {path: 'food', component: FoodComponent, children: [
      {path: 'location', component: LocationComponent}
    ]},
  ];
}