第一种:ng-class多个条件
<span ng-repeat="dictionaryItem in dataShowList" ng-class="setStyle(judgetype)" ng-if="dictionaryItem.code==judgetype">{{dictionaryItem.name}}</span>
js中
$scope.setStyle = function (colortype) {
if(colortype%5=0){
return 'label label-sm label-success';
}else if(colortype%5=1){
return 'label label-sm label-danger';
}else if(colortype%5=2){
return 'label label-sm label-warning';
}else if(colortype%5=3){
return 'label label-sm label-primary';
}else if(colortype%5=4){
return 'label label-sm label-info';
}
}
第二种
html
<span ng-repeat="dictionaryItem in dataShowList" class="label label-sm label-{{labelColorList[$index % 5]}}" + ' ng-if="dictionaryItem.code==judgetype">{{dictionaryItem.name}}</span>js
$scope.labelColorList = ["success","danger","warning","primary","info"] ;