Bird
0
0

Given this route configuration:

medium📝 component behavior Q4 of 15
Angular - Routing
Given this route configuration:
{ path: 'profile', loadChildren: () => import('./profile/profile.module').then(m => m.ProfileModule) }

What happens when the user navigates to '/profile'?
AThe router ignores the path and shows a blank page
BThe app throws an error because ProfileModule is not imported in AppModule
CThe ProfileModule is loaded immediately when the app starts
DThe ProfileModule is loaded asynchronously and its routes are activated
Step-by-Step Solution
Solution:
  1. Step 1: Understand lazy loading behavior on navigation

    When navigating to a lazy loaded route, Angular loads the module asynchronously at that moment.
  2. Step 2: Apply to given route

    Here, navigating to '/profile' triggers loading ProfileModule and activates its routes.
  3. Final Answer:

    The ProfileModule is loaded asynchronously and its routes are activated -> Option D
  4. Quick Check:

    Lazy load on navigation = A [OK]
Quick Trick: Lazy loaded modules load only on route visit [OK]
Common Mistakes:
MISTAKES
  • Thinking lazy modules load at app start
  • Assuming missing import causes error
  • Believing router ignores lazy routes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes