Bird
0
0

How do you correctly configure lazy loading for a module named OrdersModule located at ./orders/orders.module.ts in Angular routing?

easy📝 Syntax Q3 of 15
Angular - Modules
How do you correctly configure lazy loading for a module named OrdersModule located at ./orders/orders.module.ts in Angular routing?
A{ path: 'orders', loadChildren: './orders/orders.module#OrdersModule' }
B{ path: 'orders', loadChildren: () => import('./orders/orders.module').then(m => m.OrdersModule) }
C{ path: 'orders', loadChildren: () => import('./orders.module').then(m => m.OrdersModule) }
D{ path: 'orders', loadChildren: () => require('./orders/orders.module').OrdersModule }
Step-by-Step Solution
Solution:
  1. Step 1: Use dynamic import syntax

    Angular requires dynamic import() for lazy loading modules.
  2. Step 2: Specify correct path and module

    The path must point to the module file, and the module class must be referenced correctly.
  3. Final Answer:

    { path: 'orders', loadChildren: () => import('./orders/orders.module').then(m => m.OrdersModule) } -> Option B
  4. Quick Check:

    Dynamic import with correct path and module [OK]
Quick Trick: Use dynamic import with correct path [OK]
Common Mistakes:
  • Using string syntax with # which is deprecated
  • Incorrect module path or filename
  • Using require() instead of import()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes