比如:
根据
<ul style="float: left;overflow:hidden;" ng-repeat='node in nodedata' >
<li style="list-style-type:none;">
<span style="background:green;" uib-popover="{{node.nodeIndex|getNodeNameFliter}}" popover-trigger="mouseenter" type="button" class="btn btn-default dd breath_light" popover-placement="bottom">{{node.nodeIndex|getNodeNameFliter}}</span> <i class="icon-chevron-right" style="margin-left:10px;color:green;font-size:20px;"></i>
</li>
</ul>
style="background:green;"`可以根据 node.status不同的值1,2,3,4设置red,yellow,green,black如何实现呢?
在线等,没人会吗?
曾经蜡笔没有小新2017-05-15 17:06:11
html代码:使用ng-style
<ul style="float: left;overflow:hidden;" ng-repeat='node in nodedata'>
<li style="list-style-type:none;">
<span ng-style="setColor(node.status)" uib-popover="{{node.nodeIndex|getNodeNameFliter}}"
popover-trigger="mouseenter" type="button" class="btn btn-default dd breath_light"
popover-placement="bottom">{{node.nodeIndex|getNodeNameFliter}}</span>
<i class="icon-chevron-right" style="margin-left:10px;color:green;font-size:20px;"></i>
</li>
</ul>
js代码:
$scope.setColor = function (status) {
var p = "";
if (1 == status) {
p = 'red';
} else if (2 == status) {
p = 'yellow';
} else if (3 == status) {
p = 'green';
} else if (4 == status) {
p = 'black';
}
return {"background-color": p};
};
ringa_lee2017-05-15 17:06:11
现在居然还有用行内样式的
我的话会这么做
<style>
.backstyel1{background:red}
.backstyel2{background:yellow}
.backstyel3{background:green}
.backstyel4{background:black}
</style>
<span class="btn btn-default dd breath_light backstyel{{node.nodeIndex|getNodeNameFliter}}" uib-popover="{{node.nodeIndex|getNodeNameFliter}}" popover-trigger="mouseenter" type="button" class="btn btn-default dd breath_light" popover-placement="bottom">{{node.nodeIndex|getNodeNameFliter}}</span> <i class="icon-chevron-right" style="margin-left:10px;color:green;font-size:20px;"></i>