Angular 具有延迟加载模块的路由器导航

Angular 具有延迟加载模块的路由器导航,angular,angular2-routing,lazy-loading,Angular,Angular2 Routing,Lazy Loading,我们有几个延迟加载模块,路由器的配置如下: { path: 'parent', component: Parent, children: [ { path: child1, loadChildren: 'pathToModule1' } { path: child2, loadChildren: 'pathToModule1'

我们有几个延迟加载模块,路由器的配置如下:

{
    path: 'parent',
    component: Parent,
    children: [
        {
            path: child1,
            loadChildren: 'pathToModule1'
        }
        {
            path: child2,
            loadChildren: 'pathToModule1'
        }
    ]
}

- child1 
{
    path: '', 
    component: Child1 
}

- child2 
{
    path: '', 
    component: Child2 
}
所以,当我在Child1上时,a想导航到Child2

this.router.navigate(['../child2'], {relativeTo: this.activatedRoute})
我们得到了父母/孩子1/孩子2

但由于添加了延迟加载模块配置的空部分,我应该使用

this.router.navigate(['../../child2'], {relativeTo: this.activatedRoute})
因为事实上我们有父母/孩子1+''

预期行为

我们有父母/孩子2 有没有办法改变这种行为? 由于有许多嵌套的延迟加载模块,我们将得到一点好处 空部分,我们将编写../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../sibling以执行

使用指令对问题进行最小复制

任何具有延迟加载模块的应用程序。只需尝试导航到兄弟路径

只需转到“成员”并尝试使用两个按钮返回即可

角度版本:4.1.3


浏览器:任何

解决方案是将路由器配置为
解决方案
设置为
'corrected'

@NgModule({
进口:[
forRoot(路由,{relativeLinkResolution:'corrected'})
]
})
类AppModule{}
请参阅更多:

启用错误修复,以更正具有空路径的组件中的相对链接分辨率


嗨,克里斯。您是否找到了此问题的解决方案?当前版本似乎存在问题: