Bird
0
0

Given this routes array:

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

What component will display when the URL path is '/about'?
AHomeComponent
BNo component, error occurs
CAboutComponent
DBoth HomeComponent and AboutComponent
Step-by-Step Solution
Solution:
  1. Step 1: Match URL path to route

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

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

    AboutComponent -> Option C
  4. Quick Check:

    URL '/about' shows AboutComponent [OK]
Quick Trick: URL path matches route path to load component [OK]
Common Mistakes:
MISTAKES
  • Assuming empty path matches '/about'
  • Expecting multiple components to load
  • Thinking no component loads for '/about'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes