const routes: Routes = [ { path: 'feature', loadChildren: () => import('./feature/feature.module').then(m => m.FeatureModule) } ];
Lazy loading means the module is loaded only when its route is accessed for the first time. This improves startup time.
Angular uses dynamic import syntax with a promise to lazy load modules. The path must be correct and the module class referenced in then().
const routes: Routes = [ { path: 'dashboard', loadChildren: () => import('./dashboard/dashboard.module').then(m => m.Dashboard) } ];
The error occurs because the module class name used in then() does not match the exported class name. It should be 'DashboardModule' if that is the class name.
Angular loads the lazy loaded module once and reuses it for subsequent navigations, so only one instance exists.
Lazy loading improves startup performance by loading only the code needed initially, deferring other modules until required.
