1

我有以下 angularjs ng-repeat ,列状态有三个值(电话,活动,等待)

 <tr ng-repeat="person in persons">                 
 <td>{{person.id}}</td>
 <td>{{person.status}}</td> 
</tr>

我需要根据状态的值应用引导类,如下图所示

例子

4

1 回答 1

2

您需要使用ng-class指令

标记

<tr ng-repeat="person in persons">                 
   <td>{{person.id}}</td>
   <td ng-class="{'phoned':person.status === 'Phoned',
                  'active':person.status === 'Active',
                  'waiting':person.status === 'Waiting'}">
    {{person.status}}
   </td> 
</tr>

CSS

.phoned{
   background-color: blue;
}
.active{
   background-color: green;
}
.waiting{
   background-color: orange;
}
于 2015-05-30T10:50:57.970 回答