Bird
0
0

Which of the following is the correct syntax to create a RouterLink to a route named 'settings' with a parameter 'id' equal to 5?

easy📝 Syntax Q3 of 15
Angular - Routing
Which of the following is the correct syntax to create a RouterLink to a route named 'settings' with a parameter 'id' equal to 5?
A<a [routerLink]="['/settings', 5]">Settings</a>
B<a routerLink="/settings/5">Settings</a>
C<a [routerLink]="'/settings/5'">Settings</a>
D<a [routerLink]="['settings', id=5]">Settings</a>
Step-by-Step Solution
Solution:
  1. Step 1: Understand parameter passing in RouterLink

    Parameters are passed as array elements after the route path string.
  2. Step 2: Check each option

    Settings correctly uses an array with route and parameter. Others have syntax errors or wrong formats.
  3. Final Answer:

    <a [routerLink]="['/settings', 5]">Settings</a> -> Option A
  4. Quick Check:

    Array with route and param = correct RouterLink syntax [OK]
Quick Trick: Pass params as array elements after route string [OK]
Common Mistakes:
MISTAKES
  • Using string with params inside binding
  • Incorrect array syntax
  • Trying to assign param with = inside array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes