Reputation: 39
Hi I have a question here the code and data i have is here
<div class="table-row" ng-repeat="x in myData" >
<div class="table-cell" >{{x.accountNumber}}</div>
<div class="table-cell"><span class="table-cell-asset">
{{x.totalAsset/100|currency}} </span><br/>
<span class="table-cell-changes">{{x.changePercent}}%/
{{x.changeDollar}}</span></div>
</div>
changePercent is a float number that can be positive or negative or 0 i want to add a similar if/else statement to have is change color of changePercent and changeDollar for positive negative or 0. I know a controller will do the job. I wonder if i can do it with some directive inline code to finish the comparison and change the color by result.
Upvotes: 1
Views: 239
Reputation: 171690
Use ng-class
and css rules for your coloring:
<span class="table-cell-changes"
ng-class="{'green': x.changePercent > 0,
'yellow': x.changePercent == 0,
'red': x.changePercent < 0}">
{{x.changePercent}}%/{{x.changeDollar}}
</span>
Upvotes: 1