如何在 angular html 模板中动态更改 Ionic 元素的 属性?

How to dynamically change property of an Ionic element in angular html template?

如果可观察值发生变化,我想更改 ionic-chip 的轮廓 属性:

<span *ngIf="(avgRating | async) as obs">
      <ion-chip  outline= "obs.total  > 0 ? 'none' : 'outline'"> 
        // change outline property if observable changes
      </ion-chip>
</span>

是否可以在模板文件中执行此操作?

离子芯片的轮廓属性是一个布尔值。因此,您不能将 'none' 或 'outline' 设置为它,因为它们是字符串。因此,只需检查 return obs.total > 0 的输出到 outline 属性就足够了。

参考:https://ionicframework.com/docs/api/chip