4
<a href="#"
                        [routerLink]="[isTrue?'/location-1':'/location-2', '']"
                        [queryParams]="{id:loc.id,l:'loc'}">

Here when value of isTrue is true
/location-1/?id=1&l=loc

But when value of isTrue is false, I need
/location-2/?id=1&l=loc2&idL=2

So how do I modify parameter conditionally?

1 Answer 1

7

Found solution, we can also add ternary condition before object on queryParams.

[queryParams]="isTrue?{id:loc.id,l:'loc'}:{id:loc.id,l:'loc2',idL:loc.lId}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.