pbrownlee88
pbrownlee88

Reputation: 13

Changing the color of font depending on math expression within ng-style

When I enter a number into the text box I want to color of the text of another text box below to turn red depending on the value entered but I'm not sure if I have my syntax for the ng-style correct with regards to the math expression. Thank you for helping!

     ng-model="approval.groupCreditLimit" ng-style="{'color':(approval.siteTotal + approval.siteCreditLimit) > approval.groupCreditLimit) ? 'red' : 'inherit'}"  class="form-control" name="groupCreditLimit" placeholder="Group Credit Limit" >

Upvotes: 1

Views: 996

Answers (1)

Sachila Ranawaka
Sachila Ranawaka

Reputation: 41445

try something like this

ng-style="( (approval.siteTotal + approval.siteCreditLimit) > approval.groupCreditLimit) ? {'color': 'red'} : {'background-color': 'inherit'}" 

here is a working demo

Upvotes: 3

Related Questions