I have obtained a value (for example, "75.8%") as a string from an API and I need to convert it to a number in order to apply conditions.
For instance:
<div
class="container"
[ngClass]="{
'pos' : value > 0,
'neg' : value < 0
}"
*ngIf="value"
>
<span class="me-1">
{{value}} %
</span>
</div>
Note:
Essentially, I am changing the background color to green (using class 'pos') if the value is positive and to red if the value is negative.
I attempted this conversion without success since I am unsure of how to proceed.