Bird
0
0

Which method is used to add a query parameter to an existing HttpParams object in Angular?

easy🧠 Conceptual Q2 of 15
Angular - HTTP Client
Which method is used to add a query parameter to an existing HttpParams object in Angular?
Aappend()
Bpush()
Cset()
Dadd()
Step-by-Step Solution
Solution:
  1. Step 1: Understand HttpParams immutability

    HttpParams is immutable, so methods like set() return a new instance with the parameter added or replaced.
  2. Step 2: Identify the correct method

    set() adds or updates a parameter, while append() adds a new value without replacing existing ones. add() and push() do not exist on HttpParams.
  3. Final Answer:

    set() -> Option C
  4. Quick Check:

    Add param method = set() [OK]
Quick Trick: Use set() to add or update params immutably [OK]
Common Mistakes:
MISTAKES
  • Using append() which adds multiple values instead of replacing
  • Trying to use add() or push() which are invalid
  • Mutating HttpParams directly instead of reassigning

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes