Myko
Myko

Reputation: 59

Coloring a row depending on a boolean column value

I use a ui-grid in an app showing some data. The first column is a boolean value.

If this value is true I want to color the whole row green (by setting bg-success as cellclass)

How can I check for the boolean value? How can I change the whole row's color?

My setup is pretty basic, so I dont include code you know anyways ;)

Upvotes: 1

Views: 842

Answers (3)

user5650488
user5650488

Reputation:

Assuming you'll use boolOdd as the boolean and bg-error as other class, this would be the answer:

<table>
<tr ng-repeat="column in columns" ng-class="{'bg-success': boolOdd, 'bg-error': !boolOdd}">
<td>{{column.name}}</td>
<td>{{column.text}}</td>
</tr>
</table>

Upvotes: 1

Michele Ricciardi
Michele Ricciardi

Reputation: 2117

Sounds like you want to try ng-class

Could you paste sample code?

Upvotes: 0

rtn
rtn

Reputation: 2034

Have you though about using ngClass.

Could add this on the <tr ng-class="{'bg-success' ? yourBool }">

Upvotes: 0

Related Questions