artur shevtsov
artur shevtsov

Reputation: 77

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

I would like to change the outline property of ionic-chip if an observable changes:

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

Is it possible to do this in the template file?

Upvotes: 0

Views: 475

Answers (1)

Pradyumna Pasumarty
Pradyumna Pasumarty

Reputation: 201

The outline property of an ion-chip is a boolean value. Therefore, you cannot set 'none' or 'outline' to it as they are strings. Therefore, it would just be enough to check and return output of obs.total > 0 to the outline attribute.

Ref: https://ionicframework.com/docs/api/chip

Upvotes: 1

Related Questions