例如:
根據
<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};
};
迷茫2017-05-15 17:06:11
據我所知CSS沒有這樣的功能,CSS最有名的是媒體查詢,它可以根據不同的螢幕大小,選用不用的CSS樣式。像題主這樣的要求,我想只能靠JS配合來實現了。
ringa_lee2017-05-15 17:06:11
現在居然還有用行內樣式的
我的話會這麼做
<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>