'send "&" in url angular

I'm using the Angular version 12 I want to send the following object in query params:

{
  dynamicQueryOperators: 6&dynamicQueryOperators=8
}

But in the end, the URL that is sent to the server is like this Request URL:

...dynamicQueryOperators=6**%26**dynamicQueryOperators=8

How can I prevent "&" from changing to "%26"?



Solution 1:[1]

I was able to fix the bug by sending the variable as an array. If you send the variable like below:

this.query['dynamicQueryOperators'] = [6, 8];

Your header will be automatically created with two identical object keys and the character "&" will be placed between them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 amir marjani