我似乎無法在子路線之間導航。兒童路線之間的導航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路由不太容易進入服務。 –