Bird
0
0

Given this route configuration, what happens when the user navigates to '/profile'?

medium📝 Predict Output Q4 of 15
Angular - Performance Optimization
Given this route configuration, what happens when the user navigates to '/profile'?
{ path: 'profile', loadChildren: () => import('./profile/profile.module').then(m => m.ProfileModule) }
AProfileModule is loaded immediately when the app starts
BNavigation to '/profile' will fail due to missing component
CThe ProfileModule is loaded only when '/profile' is visited
DThe app preloads ProfileModule regardless of navigation
Step-by-Step Solution
Solution:
  1. Step 1: Understand lazy loading behavior

    Using loadChildren with dynamic import means the module loads only on navigation to that route.
  2. Step 2: Analyze options

    The ProfileModule is loaded only when '/profile' is visited correctly states the module loads on demand. ProfileModule is loaded immediately when the app starts is wrong because lazy loading delays loading. Navigation to '/profile' will fail due to missing component is incorrect as module contains components. The app preloads ProfileModule regardless of navigation describes preloading, which is not shown here.
  3. Final Answer:

    The ProfileModule is loaded only when '/profile' is visited -> Option C
  4. Quick Check:

    Lazy loaded module loads on route visit = true [OK]
Quick Trick: Lazy loaded modules load only when their route is accessed [OK]
Common Mistakes:
  • Assuming lazy loaded modules load at app start
  • Confusing lazy loading with preloading
  • Thinking navigation fails without explicit component

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes