css - change the font color based on value angular js -


i using angular js , used ng-repeat loop , show details in page,is there possibility change font color based on value?

<li ng-repeat="s in vm.states" >                           <span>{{s.name}}</span>   <span>{{s.state}}</span>  </li>  test1 -error(red) test2-warning(blue) test 3-ignored(green) 

here s.state value can error,warning,ignored can show different font colors these states via angular or css

you can achieve following code:

<li ng-repeat="s in vm.states" >                           <span>{{s.name}}</span>   <span ng-class="{'color-red': s.state === 'error', 'color-blue': s.state === 'warning', 'color-green': s.state === 'ignored'}">{{s.state}}</span> </li> 

where 'color-red', 'color-blue', 'color-green' css classes.

see in plunker.

check documentation ng-class.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -