[英]Angular 9 lazy load each component of a module
I have a module who has a big set of components that are accessed by different subroutes.我有一个模块,它有一大组可通过不同子路由访问的组件。 I'm already lazy loading the module, but I'd like to know if it's possible to lazy load the subcomponents:
我已经在延迟加载模块,但我想知道是否可以延迟加载子组件:
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]
}
]
}
];
Any idea if that's possible?知道这可能吗?
您可以在那里阅读有关组件延迟加载的信息: https : //johnpapa.net/angular-9-lazy-loading-components/但我认为将每个组件与模块分开是更好的主意
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.