Bird
0
0

Given this route config, what happens when navigating to '/settings'?

medium📝 component behavior Q4 of 15
Angular - Standalone Components
Given this route config, what happens when navigating to '/settings'?
{ path: 'settings', loadComponent: () => import('./settings.component').then(m => m.SettingsComponent) }
ASettingsComponent is loaded immediately when the app starts.
BThe SettingsComponent is loaded only when '/settings' is visited.
CAn error occurs because loadComponent is not valid here.
DThe route redirects to the root path automatically.
Step-by-Step Solution
Solution:
  1. Step 1: Understand loadComponent behavior

    loadComponent dynamically imports the component only when the route is accessed.
  2. Step 2: Apply to '/settings' route

    When navigating to '/settings', Angular loads SettingsComponent lazily at that moment.
  3. Final Answer:

    The SettingsComponent is loaded only when '/settings' is visited. -> Option B
  4. Quick Check:

    Lazy load triggers on route visit = loadComponent works [OK]
Quick Trick: loadComponent loads component only on route access [OK]
Common Mistakes:
  • Assuming component loads at app start
  • Thinking loadComponent causes errors
  • Believing route redirects automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes