经过几天的搜索,我无法确定使用相对路径使命名路由器插座中的组件影响主路由组件的正确方法。
路线:
let routes: Routes = [
{ path: '', redirectTo: 'auth/portfolio/home/1', pathMatch: 'full'},
{
path: 'auth/:module',
component: AuthComponent,
children: [
{ path: 'home/:value', component: HomeComponent},
{ path: 'home2/:value', component: Home2Component},
{ path: 'details', component: DetailComponent, outlet: 'aux'},
{ path: 'details2', component: Detail2Component, outlet: 'aux'}
]
}
];

以下是显示问题的Plunker。
问题:让子路由组件影响命名路由插座中的兄弟组件的正确语法是什么,反之亦然?如果可能的话,你能回复一个有效的工作人员吗?
更新1: 作为一个短期的黑客攻击,我创建了一个AuthRouterService,它在AuthComponent中为子组件执行路由。 AuthRouterService位于AuthComponent的Providers数组中,因此所有子节点都获得一个服务。我在这里留下这个问题,万一有人找到了正确的语法,否定了这个hackaround的必要性。如果我没有收到回复,我会在一周左右的时间内完成这个问题。
请参阅Plunker此处了解AuthRoutingService以及我如何将其用作hackaround。
由于
答案 0 :(得分:0)
作为一个短期的解决方法,我创建了一个AuthRouterService,用于对AuthComponent中的子组件进行路由。 AuthRouterService位于AuthComponent的Providers数组中,因此所有子级都获得一项服务。如果有人发现适当的语法消除了这种变通方法的需要,我将在这里留下这个问题。如果我没有回音,我会在大约一周的时间内通过此骇客攻击将其标记为完成。