Bird
0
0

Given this route configuration:

medium📝 component behavior Q13 of 15
Angular - Routing
Given this route configuration:
const routes = [
  { path: '', component: HomeComponent },
  { path: 'about', component: AboutComponent }
];

What component will Angular display when the URL path is /about?
AAboutComponent
BHomeComponent
CNo component, shows error
DBoth HomeComponent and AboutComponent
Step-by-Step Solution
Solution:
  1. Step 1: Match URL path to route

    The URL path '/about' matches the route with path 'about'.
  2. Step 2: Identify component for matched route

    The route with path 'about' uses AboutComponent.
  3. Final Answer:

    AboutComponent -> Option A
  4. Quick Check:

    Path '/about' shows AboutComponent [OK]
Quick Trick: Match URL path exactly to route path to find component [OK]
Common Mistakes:
MISTAKES
  • Assuming empty path '' matches '/about'
  • Thinking multiple components show at once
  • Expecting error for valid path

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes