Bird
0
0

Identify the error in this route config for lazy loading a standalone component:

medium📝 Debug Q14 of 15
Angular - Standalone Components
Identify the error in this route config for lazy loading a standalone component:
{ path: 'profile', loadComponent: import('./profile.component').then(m => m.ProfileComponent) }
AMissing arrow function wrapping the import call
BUsing loadComponent instead of component property
CIncorrect path string format
DMissing import statement at the top of the file
Step-by-Step Solution
Solution:
  1. Step 1: Check loadComponent syntax

    The loadComponent property must be a function returning a Promise, so it needs an arrow function wrapping the import.
  2. Step 2: Identify missing arrow function

    The code calls import directly without wrapping in a function, causing the component to load eagerly or a runtime error when the router tries to invoke it.
  3. Final Answer:

    Missing arrow function wrapping the import call -> Option A
  4. Quick Check:

    loadComponent requires () => import(...) [OK]
Quick Trick: Wrap import in arrow function for loadComponent [OK]
Common Mistakes:
  • Calling import directly without function
  • Confusing loadComponent with component property
  • Thinking import must be at file top

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes