【发布时间】:2017-09-08 06:35:40
【问题描述】:
在使用延迟加载模块的路由器导航时似乎存在问题。如果我删除延迟加载,这会很好。但这是我根据延迟加载模块的设置:
在我的 app.template 中,我定义了主路由器插座。
我有以下根应用路由器
export const ROUTES: Routes = [
{
path: 'user/:id', loadChildren: './user/profile/profile.module#ProfileModule'
}
]
当配置文件模块加载到主路由器出口时,它将显示一个带有两个路由选项卡和内部配置文件的页面。模块我定义了以下子路由
const ROUTES: Routes = [
{
path: '', component: ProfileComponent,
children: [
{ path: 'subPath1', loadChildren: '../subModule1/subModule1.module#SubModule1Module' },
{ path: 'subPath2', loadChildren: '../subModule2/subModule2.module#SubModule2Module' },
]
}
];
@NgModule({
imports: [
RouterModule.forChild(ROUTES),
....
]
}
在 profile.template 中,我有这样定义的路由选项卡
<nav md-tab-nav-bar>
<a class="tab-label" md-tab-link [routerLink]="'subPath1'" routerLinkActive #rla="routerLinkActive" [active]="rla.isActive">
Sub path 1
</a>
<a class="tab-label" md-tab-link [routerLink]="'subPath2'" routerLinkActive #rla="routerLinkActive" [active]="rla.isActive">
Sub path 2
</a>
</nav>
<router-outlet></router-outlet>
当我路由时,例如到 /user/:id/subPath2 我希望 subModule2 被加载到 md-tab-nav-bar 的路由器插座中,但它被加载到主应用程序路由器插座中。这将关闭 profile.component 并仅显示 submodule2 而不是在选项卡内显示它。
知道为什么这不适用于延迟加载模块吗?
【问题讨论】:
标签: angular angular2-routing angular-material2