Reputation: 763
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?
Upvotes: 0
Views: 83
Reputation: 116
You can read about component lazy-loading there: https://johnpapa.net/angular-9-lazy-loading-components/ But i think that separate each component to module is better idea
Upvotes: 1