CodeZettaInterview Hub

Angular · Routing · Mid-Level · Architecture

How do you lazy load a standalone route?

Short Interview Answer

Use loadComponent: () => import(...).then(m => m.FeatureComponent) on the route.

Detailed Explanation

Code-splits the feature. Combine with canMatch/canActivate for auth. Prefer standalone lazy routes over NgModule lazy loading in new apps.

Example

{ path: 'admin', loadComponent: () => import('./admin.component').then(m => m.AdminComponent) }

Did you know this answer?