我想實現 跳轉按鈕是紅色,刪除按鈕是藍色,添加是白色,但是目前這樣循環的話,全是“btn-warning”這個樣式,也就是紅色!
angular.module('demoAPP').controller('demoCtrl', function($scope) {
var demoData = [
{
"Name" : "操作",
"action" : "跳转"
},
{
"Name" : "操作",
"action" : "删除"
}
{
"Name" : "操作",
"action" : "添加"
}
]
$scope.demo = demoData;
});
<table>
<tr ng-repeat="item in demo">
<td>{{item.Name}}</td>
<td><button type="button" class="btn btn-warning">{{item.action}}</button></td>
</tr>
</table>
过去多啦不再A梦2017-05-15 17:15:42
ng-class="{'樣式':item.action=='跳轉'}"
ng-class="{'樣式':item.action=='加'}"
ng-class="{ '樣式':item.action=='修改'}"
ng-class為true時執行樣式