我似乎无法在子路线之间导航。儿童路线之间的导航Angular 2
路由器概述:
path: 'parent', component: parentComponent,
children: [
{ path: '', redirectTo: 'child1', pathMatch: 'full' },
{ path: 'child1', component: child1Component },
{ path: 'child2', component: child2Component },
{ path: 'new/:type', component: child3Component },
{ path: '**', component: PageNotFoundComponent }
]
我在的child1组件试图导航到新/型路线,像这样:
this._router.navigate(['new', objType], { relativeTo: this._route });
但我不断收到错误:无法匹配任何路线。网址细分:“新/资产”。
如果我手动插入网址,它工作正常。
帮助将不胜感激,谢谢!
这工作,谢谢!我有这么多问题的原因是因为我在服务中使用导航操作,而不是组件本身。 –
我明白了。 relativeTo路由不太容易进入服务。 –