Consider an Angular app using standalone components with lazy loading via the router. What is the expected behavior when the user navigates to a route configured to lazy load a standalone component?
const routes = [ { path: 'profile', loadComponent: () => import('./profile.component').then(m => m.ProfileComponent) } ];
Think about how lazy loading defers loading code until needed.
Lazy loading with loadComponent loads the component code only when the route is activated, reducing initial bundle size.
Which of the following route configurations correctly lazy loads a standalone component named DashboardComponent?
Remember the property name used for lazy loading standalone components is loadComponent.
The loadComponent property expects a function returning a promise resolving to the component class.
Given this route config, the app throws an error when navigating to '/settings'. What is the cause?
const routes = [
{ path: 'settings', loadComponent: () => import('./settings.component').then(m => m.SettingsModule) }
];Check what is being imported and returned by the promise.
loadComponent must return a standalone component class, not a module. Returning a module causes Angular to fail loading the component.
An Angular app uses lazy loading with standalone components for several feature routes. What is the expected effect on the initial JavaScript bundle size and app startup time?
Think about how lazy loading affects what code is downloaded at startup.
Lazy loading defers loading feature components until navigation, reducing initial bundle size and improving startup speed.
Choose the correct statement about lazy loading standalone components in Angular.
Recall Angular's recent support for standalone components and routing.
Angular allows lazy loading standalone components directly via loadComponent without needing NgModules.