【问题标题】:Condition in queryParams angular2queryParams angular2 中的条件
【发布时间】:2016-11-30 05:58:34
【问题描述】:
<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

那么如何有条件地修改参数呢?

【问题讨论】:

    标签: angular routeparams


    【解决方案1】:

    找到解决方案, 我们还可以在queryParams 的对象之前添加三元条件。

    [queryParams]="isTrue?{id:loc.id,l:'loc'}:{id:loc.id,l:'loc2',idL:loc.lId}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-09
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      • 2018-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多