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.
Comments
Post a Comment