AngularJS ng expression expression not working as expected?

I use ng-repeat

to indicate the number of home runs versus a run in a simple table. I am applying the class based on which the team wins using the following code snippet:

  <tr ng-class="{winning : game.linescore.r.home > game.linescore.r.away}">
    <td>{{ game.home_team_name }}</td>
    <td>{{ game.linescore.r.home }}</td>
  </tr>

      

The code works if the number of home runs is greater than the number of runs, but only if that number is less than 10.

Example:

Performance as expected: 9> 5

Doesn't work: 11> 5

I am wondering if anyone knows how to solve this problem?

+3


source to share


1 answer


If your values ​​are strings then it makes sense, like '9' > '5'

, but '11' < '5'

. You will need to convert to an integer for example. parseInt

...



+2


source







All Articles