Bird
0
0

Consider the template snippet:

medium📝 component behavior Q4 of 15
Angular - Routing
Consider the template snippet:
<a [routerLink]="['/account', accountId]">Account Details</a>

If accountId = 100, which URL will the link navigate to when clicked?
A/account/100
B/account?accountId=100
C/account/accountId
D/account
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the routerLink array syntax

    The array syntax concatenates segments to form the URL.
  2. Step 2: Substitute the variable

    With accountId = 100, the URL becomes '/account/100'.
  3. Final Answer:

    /account/100 -> Option A
  4. Quick Check:

    Array syntax appends parameters as path segments. [OK]
Quick Trick: Array syntax builds URL segments in RouterLink. [OK]
Common Mistakes:
MISTAKES
  • Assuming parameters are query strings.
  • Using string interpolation incorrectly.
  • Ignoring the array syntax effect.

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes