3

I am using ng-repeat to list out the number of home runs vs away run in a simple table. I am applying a class based on which team is winning using the following snippet of code:

  <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 away runs but only if this number is less than 10.

Example:

Works As Expected: 9 > 5

Does Not Work: 11 > 5

I am wondering does anyone know how overcome this issue?

2
  • 2
    Are your scores numbers or strings? 11 > 5 but '11' < '5' Commented Mar 24, 2017 at 22:51
  • I am retrieving the data from a JSON API feed so I'd need to convert it to numbers first. Thanks Commented Mar 24, 2017 at 22:56

1 Answer 1

2

If your values are strings, then it makes sense, as '9' > '5' but '11' < '5'. You'll need to convert to integer with e.g. parseInt.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.