Angular 2: Have Child Route Component Replace Parent in router-outlet

前端 未结 5 1656
猫巷女王i
猫巷女王i 2020-12-28 13:21

Is there a way to display a child route in the parent route\'s ?

For example, let\'s say we have two routes:

/users         


        
5条回答
  •  [愿得一人]
    2020-12-28 14:15

    I had the same issue. This is how I fixed it:

    const routes: Routes = [
       {
        path: '',
        children: [
             {
               path: '',
               component: ParentComponent,
             },
             {
               path: 'child',
               component: ChildComponent,
             }
         ]
       }
    ];  
    

提交回复
热议问题