I have a counter that counts down to 0, and I wanted to set the background color of an element according to the counter value:
- Green: 20 or higher
- Orange: 10 to 20
- Red: 9 or lower
What I did is to apply 3 different classes to the element and give a different condition to each one of them:
<p [class.green]="20 <= counter" [class.orange]="10 <= counter && counter <= 20" [class.red]="10 > counter">
{{ counter }}
</p>
Is there a better (or at least more corrected) way to achieve the desired outcome?