我想用可選的參數調用路線。無法匹配任何路線:使用查詢參數
我的路由器
const appRoutes: Routes = [
{ path: '', redirectTo: 'bo', pathMatch: 'full' },
{ path: 'login', component: LoginComponent },
{ path: 'bo', component: LayoutComponent,
children: [
{ path: '' , redirectTo: 'history', pathMatch: 'full'},
{ path: 'history', component: HistoryComponent } ,
{ path: 'history/details:id', component: DetailsComponent }
]
},
];
我該如何稱呼它
this.router.navigate(['./details', {id: myVarID}], { relativeTo: this.route });
錯誤:無法匹配任何路線: '波/歷史/詳細信息,ID = myIdValue'
但它的工作原理,如果我用斜線在路由器中定義它,並通過手動插入URL來調用它:
{ path: 'history/details/:id', component: DetailsComponent }
即使我添加';'而不是路由器中的「/」,它不起作用。我想用router.navigate函數調用路由!
嘿!它仍然不起作用,錯誤是一樣的。我可以調用路由,如果我手動插入一個斜線,但功能導航使用';'調用它; –