AngularJS bootstrap class
AngularJS bootstrap class
我有以下 angularjs ng-repeat,列状态有三个值(已通话、活动、等待)
<tr ng-repeat="person in persons">
<td>{{person.id}}</td>
<td>{{person.status}}</td>
</tr>
我需要申请bootstrap class 取决于status的值,如下图
您需要使用 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;
}
我有以下 angularjs ng-repeat,列状态有三个值(已通话、活动、等待)
<tr ng-repeat="person in persons">
<td>{{person.id}}</td>
<td>{{person.status}}</td>
</tr>
我需要申请bootstrap class 取决于status的值,如下图
您需要使用 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;
}