Bird
0
0

Given this route config:

medium📝 component behavior Q13 of 15
Angular - Routing
Given this route config:
{ path: 'dashboard', component: DashboardComponent, children: [ { path: 'stats', component: StatsComponent } ] }

What happens when navigating to /dashboard/stats?
AOnly StatsComponent loads, DashboardComponent is ignored
BDashboardComponent loads with StatsComponent displayed inside its router-outlet
CDashboardComponent loads but StatsComponent does not display
DNavigation fails with an error
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested route rendering

    Child routes render their components inside the parent's <router-outlet>.
  2. Step 2: Apply to given URL

    At /dashboard/stats, DashboardComponent loads first, then StatsComponent loads inside its router-outlet.
  3. Final Answer:

    DashboardComponent loads with StatsComponent displayed inside its router-outlet -> Option B
  4. Quick Check:

    Child route renders inside parent component [OK]
Quick Trick: Child shows inside parent's router-outlet on nested URL [OK]
Common Mistakes:
MISTAKES
  • Expecting child component to replace parent
  • Forgetting to add router-outlet in parent
  • Assuming navigation error without cause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes