I want to compare angular 2 expressions. I got array of data in numeric string from my database i need to convert this to number before give a condition with ngClass for styling. how can i convert this type. any idea?
<td [ngClass]= "{'positive': gbh.Last > 0, 'negative': gbh.Last < 0}"> {{gbh.Last}} </td>
This answer is the typescript way: so answer
Number('1234') // 1234
Number('9BX9') // NaN
The other answer looks like it would be for int not numbers. You are better off using the plus symbol.
var x = "32";
var y = +x; // y: number
Ref answer:
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