我想路由到“配置”路由器,该路由器嵌套了 2 个插座,但我无法找出正确的方法。
<router>
<router name="main">
<router name="config">
</router>
</router>
</router>
在我的 routing.ts 中,我创建了两种访问组件的方法:
export const routes: Routes = [
{
// Entrypoint.
path: 'Foo', component: FooComponent, canActivate: [IsServerOnlineGuard], children: [
path: 'Bar', component: BarComponent, outlet: 'main', children: [
{ path: 'Smtp', component: smtpComponent, outlet: 'config' } // registered as a child
],
path: 'Smtp', component: smtpComponent, outlet: 'config' }, // registered under the "main" component
},
]
},
{ path: '', pathMatch: 'full', redirectTo: 'CSI' },
{ path: '**', redirectTo: 'CSI' },
];
我尝试以两种方式导航到那里。
public RouteToConfigOutlet(componentName: string) {
this._router.navigate([`/(main:BarComponent)/`, {
outlets: {
config: ['Smtp']
}
}]);
}
public RouteToConfigOutlet(componentName: string) {
this._router.navigate([``, {
outlets: {
main: ['BarComponent'],
config: ['Smtp']
}
}]);
}
唉,我无法让我的组件出现,并试图找到到达那里的正确方法。