I am looking forward to color some asynchronously received data in green or red, depending on its value.
To take care of race conditions, I used a Subject, which broadcasts an Object containing the data that I'm interested in.
I succeeded in doing what I wanted, but the resulting code is quite ugly :
<span [ngClass]="{greenClass: isPositive((mySubject | async)?.fieldData), redClass: !isPositive((mySubject | async)?.fieldData)}">
{{(mySubject | async)?.fieldData | number:'1.0-1' }}
</span>
Is there a better way to tackle this ? I tried to put a ternary expression in ngClass but it didn't work. Moving code back to my controller is a no-go as it would result in the creation of ten variables straight away.