我试图使用router.navigate()方法在组件内部单击按钮时重定向到另一个组件。我正在使用备用路由器插座。但是每次我得到这个
Error: Cannot match any routes: 'listproducts'
app-routing-module.ts:
const routes: Routes = [
{ path: "", component: IndexComponent, pathMatch: 'full' },
{ path: "home",
component: HomeComponent ,
children: [
{ path: 'additem', component: AdditemComponent, outlet: "mainOutlet" },
{ path: 'bookitem', component: BookitemComponent, outlet: "mainOutlet" },
{ path: 'listproducts', component: ListProductsComponent, outlet: "mainOutlet" },
{ path: 'listorders', component: ListOrdersComponent, outlet: "mainOutlet" },
{ path: 'viewcart', component: ViewCartComponent, outlet: "mainOutlet"}
],
canActivate: [AuthGuard]
}
];
组件:
CreateOrder(customer: Customer){
<<do something>>
this.router.navigate([{ outlets: {mainOutlet: 'listproducts'}}]);
}
有些问题的标题相似,但都与从html模板重定向有关。