2015-05-30 102 views
1

我有以下angularjs NG重複,列的狀態有三個值(打電話,活動,等待)AngularJS引導類

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

我需要申請引導類取決於狀態的值,如下所示圖像

example

回答

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; 
}