Bird
0
0

Consider this route setup:

medium📝 component behavior Q5 of 15
Angular - Routing
Consider this route setup:
const routes = [
  { path: 'user/:id', component: UserComponent }
];

What URL will match this route and pass the parameter id as '42'?
A/user/42
B/user?id=42
C/user/:id=42
D/user/42/details
Step-by-Step Solution
Solution:
  1. Step 1: Understand route parameter syntax

    Route with ':id' expects a segment after 'user' as the id value.
  2. Step 2: Match URL format

    /user/42 matches and passes '42' as id; query params or extra segments don't match.
  3. Final Answer:

    /user/42 -> Option A
  4. Quick Check:

    Route param in path = /user/42 [OK]
Quick Trick: Route params go in path segments, not query string [OK]
Common Mistakes:
MISTAKES
  • Using query string instead of path param
  • Adding extra segments not defined in route
  • Misusing colon syntax in URL

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes