I'm using an ionic ion-icon
<ion-icon name="checkmark" [class]="condition ? 'class1' : ''"></ion-icon>
I'd like to add an extra class if the condition is true, but dont add the extra class if the condition is false.
Problem is, if the condition is false it removes all the pre-defined classes on the icon from Ionic Framework.
Try to avoid binding to class directly.
Use either
[class.class1]="condition"
or
[ngClass]="condition ? 'class1' : ''"
With binding to class you explicitly bind the whole property value, instead of a single class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With