<a href="#"
[routerLink]="[isTrue?'/location-1':'/location-2', '']"
[queryParams]="{id:loc.id,l:'loc'}">这里,当isTrue的值为true时
/location-1/?id=1&l=loc
但是当isTrue的值为false时,我需要
/location-2/?id=1&l=loc2&idL=2
那么如何有条件地修改参数呢?
发布于 2016-11-30 06:11:04
找到解决方案后,我们还可以在queryParams上在对象之前添加三元条件。
[queryParams]="isTrue?{id:loc.id,l:'loc'}:{id:loc.id,l:'loc2',idL:loc.lId}"https://stackoverflow.com/questions/40881327
复制相似问题