[英]Routing to deep nested component Angular 2+
I have a route like this: 我有一条这样的路线:
{
path: 'parent',
children: [
{
path: '',
component: ParentComponent
},
{
path: 'child1',
children: [
{
path: ':childID',
component: Child1Component
}
]
},
{
path: 'child2',
children: [
{
path: ':childID',
component: Child2Component
}
]
}
]
}
Now I want to call route for child1/childID. 现在,我想为child1 / childID调用路由。 How do I route to it?
我该如何前往?
Right now I use this: 现在我用这个:
this._router.navigate(["child1", auction_ID]);
but it does not routes back to parent 但它不会路由回到父级
You have to start at the "top" when you are navigating to a certain route. 导航到特定路线时,您必须从“顶部”开始。 In your case, you want to go to
parent -> child1 -> :childID
so you have to pass all those parts in the navigate
method. 对于您的情况,您想转到
parent -> child1 -> :childID
因此您必须在navigate
方法中传递所有这些部分。
Navigate to the Child 导航到孩子
this._router.navigate(['parent', 'child1', auction_ID]);
Navigate to the Parent 导航到父级
this._router.navigate(['parent']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.