路由到深嵌套的组件角2+

路由到深嵌套的组件角2+

问题描述:

我有这样的路线:路由到深嵌套的组件角2+

{ 
    path: 'parent', 
    children: [ 
     { 
      path: '', 
      component: ParentComponent 
     }, 
     { 
      path: 'child1', 
      children: [ 
       { 
        path: ':childID', 
        component: Child1Component 
       } 
      ] 
     }, 
     { 
      path: 'child2', 
      children: [ 
       { 
        path: ':childID', 
        component: Child2Component 
       } 
      ] 
     } 
    ] 
} 

现在我想呼吁child1/childID的路线。我如何路由到它?

现在我用这个:

this._router.navigate(["child1", auction_ID]); 

但它不会路由回父

+0

*如果你想从孩子去父母“但它没有路由回父” * ,你应该这样做:'this._router.navigate([“/ parent”]):' – developer033

+0

如果你想导航到子路由,你需要'navigate([“parent”,“child1” ,auction_ID]) –

你必须在启动“顶”,当你浏览到某条路。在你的情况下,你想要去parent -> child1 -> :childID,所以你必须通过navigate方法中的所有部分。

导航到儿童

this._router.navigate(['parent', 'child1', auction_ID]); 

导航到父

this._router.navigate(['parent']);