我有以下路线
{ path: '', loadChildren: './home/home.module#HomeModule' }
当用户登录时,我想为同一根路径加载不同的模块。
根据用户是否已登录,路由到页面的正确方法是什么。
使用resetconfig似乎是要走的路。但我不知道如何通过延迟加载来实现这一点。我在应用程序加载期间调用resetConfig。
this.router.resetConfig([
{ path: '', loadChildren: './user/user.module#UserModule' },
]);
但是我可能还需要在user.module中动态指定子根,因为如果它们已经在模块文件中定义,则路由将被覆盖。
const ROUTES: Routes = [
{ path: '', component: UserComponent }
];
@NgModule({
imports: [
RouterModule.forChild(ROUTES),
],
declarations: [
UserComponent
],
exports: [UserComponent],
providers: []
})
export class UserModule {
}
知道如何通过延迟加载实现resetConfig吗?