javascript - Convert numeric string to number in angular 2 -
i want compare angular 2 expressions. got array of data in numeric string database need convert number before give condition ngclass styling. how can convert type. idea?
<td [ngclass]= "{'positive': gbh.last > 0, 'negative': gbh.last < 0}"> {{gbh.last}} </td>
as far know, can not convert numeric string number inside angular expression.
the best practice define method in controller solve expression using 'parseint'
function ispositive (x: string, y: number): boolean { return (parseint(x, 10) < y); }
Comments
Post a Comment