Bird
0
0

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

medium📝 component behavior Q13 of 15
Angular - Standalone Components
Given this route config, what happens when navigating to '/dashboard'?
{ path: 'dashboard', loadComponent: () => import('./dashboard.component').then(m => m.DashboardComponent) }
AThe DashboardComponent is loaded immediately when the app starts
BThe DashboardComponent is loaded only when '/dashboard' is visited
CThe DashboardComponent is never loaded
DThe app throws a runtime error due to missing component
Step-by-Step Solution
Solution:
  1. Step 1: Understand loadComponent behavior

    Using loadComponent with dynamic import delays loading the component until the route is accessed.
  2. Step 2: Apply to '/dashboard' route

    The DashboardComponent will load only when the user navigates to '/dashboard', not before.
  3. Final Answer:

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

    loadComponent = lazy load on route visit [OK]
Quick Trick: loadComponent loads component on route visit only [OK]
Common Mistakes:
  • Assuming component loads at app start
  • Thinking component never loads
  • Expecting runtime error without import

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes