Bird
0
0

Which of the following is the correct syntax to lazy load a module in Angular routing?

easy📝 Syntax Q12 of 15
Angular - Performance Optimization
Which of the following is the correct syntax to lazy load a module in Angular routing?
A{ path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) }
B{ path: 'admin', loadChildren: './admin/admin.module#AdminModule' }
C{ path: 'admin', component: AdminModule }
D{ path: 'admin', loadModule: () => import('./admin/admin.module') }
Step-by-Step Solution
Solution:
  1. Step 1: Recall Angular lazy loading syntax

    Angular uses dynamic import with loadChildren returning a promise resolving to the module.
  2. Step 2: Match syntax to options

    { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) } uses the correct arrow function with dynamic import and then to get the module class.
  3. Final Answer:

    { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) } -> Option A
  4. Quick Check:

    Dynamic import + loadChildren = { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) } [OK]
Quick Trick: Use arrow function with import().then() for lazy loading [OK]
Common Mistakes:
  • Using deprecated string syntax for loadChildren
  • Confusing component with module in route config
  • Using wrong property name like loadModule

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes