Currently, I am facing a situation where I want to dynamically add a class to my view using ngClass based on changes in the output value. The output value is dependent on the response received from an API, and I am fetching data from the endpoint every second for a Simple Forex Application.
Initially, I attempted two-way data binding with ngModel and events, but I encountered screen flickering issues.
I would greatly appreciate any advice or suggestions on how to handle this scenario.
Below is a snippet of the code:
<tbody>
<tr *ngFor="let data of tableData">
..........
<td>{{ data.price }}</td>
</tr>
</tbody>
My goal is to assign a class to the data.price value based on its changes. For instance, if the initial value is 100, and on the next response it becomes 101, I want to apply a green background class. Similarly, if the value reduces to 99, I would like to add a red background class. However, due to the data changing frequently every second, I am struggling to manage the state and apply the appropriate classes.