Bird
0
0

Why is it recommended to use [routerLink] with an array instead of a string path for navigation in Angular?

hard🧠 Conceptual Q10 of 15
Angular - Routing
Why is it recommended to use [routerLink] with an array instead of a string path for navigation in Angular?
ABecause arrays automatically add query parameters to the URL.
BBecause arrays allow Angular to build URLs safely and handle parameters correctly.
CBecause strings cause Angular to reload the entire page.
DBecause strings are deprecated in Angular routing.
Step-by-Step Solution
Solution:
  1. Step 1: Understand URL building in Angular Router

    Using arrays lets Angular join path segments and encode parameters safely.
  2. Step 2: Evaluate other options

    Strings do not cause reloads or are deprecated; arrays do not add query params automatically.
  3. Final Answer:

    Because arrays allow Angular to build URLs safely and handle parameters correctly. -> Option B
  4. Quick Check:

    Arrays build safe URLs with params [OK]
Quick Trick: Use arrays to build safe URLs with parameters [OK]
Common Mistakes:
MISTAKES
  • Thinking strings cause reload
  • Assuming arrays add query params
  • Believing strings are deprecated

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes