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?

vusan
  • 5,221
  • 4
  • 46
  • 81

1 Answers1

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}"
vusan
  • 5,221
  • 4
  • 46
  • 81