Angular 角度9延迟加载模块的每个组件
我有一个模块,它有一大组由不同子例程访问的组件。我已经延迟加载模块,但我想知道是否可以延迟加载子组件:Angular 角度9延迟加载模块的每个组件,angular,angular9,Angular,Angular9,我有一个模块,它有一大组由不同子例程访问的组件。我已经延迟加载模块,但我想知道是否可以延迟加载子组件: const appRoutes: Routes = [ { path: '', component: HomeComponent, canActivate: [AuthGuardService], children: [ { path: '', component: DashboardComponent,
const appRoutes: Routes = [
{
path: '',
component: HomeComponent,
canActivate: [AuthGuardService],
children: [
{
path: '',
component: DashboardComponent,
canActivate: [AuthGuardService]
},
{
path: 'users',
component: UsersComponent, // I want to lazy load that
canActivate: [AuthGuardService]
},
{
path: 'account',
component: AccountComponent, // I want to lazy load that
canActivate: [AuthGuardService]
},
{
path: 'invoices',
component: InvoicesComponent, // I want to lazy load that
canActivate: [AuthGuardService]
},
{
path: 'upgrade',
component: StripeFormComponent, // I want to lazy load that
canActivate: [AuthGuardService]
}
]
}
];
如果可能的话,你知道吗?你可以在那里阅读关于组件延迟加载的内容:
但我认为将每个组件与模块分开是更好的主意这可能是个坏主意。在这种情况下,最好只使用单独的模块。