我有自举选项卡,我想根据从服务器收到的数据(相应数据集的颜色代码)为活动选项卡分配一些css属性。如何使用angularjs覆盖边框颜色的css值到活动选项卡?
这是HTML和CSS代码:
<div class="tabbable tabs-left">
<!--style for the tabs border -->
<ul id='myTabs' class="nav nav-tabs" ng-style="{'border-right-color':[currentData.colorCode]}">
<!-- Active tab -->
<li ng-class="getTabClass(0)" ng-click="setActiveTab(0)" class="active"><a href="#tab0" data-toggle="tab">Set 1</a></li>
<li ng-class="getTabClass(1)" ng-click="setActiveTab(1)" ><a href="#tab1" data-toggle="tab">Set 2</a></li>
<li ng-class="getTabClass(0)" ng-click="setActiveTab(2)"><a href="#tab0" data-toggle="tab">Set 3</a></li>
<li ng-class="getTabClass(1)" ng-click="setActiveTab(3)" ><a href="#tab1" data-toggle="tab">Set 4</a></li>
</ul>
CSS代码:
.tabs-left>.nav-tabs .active>a, .tabs-left>.nav-tabs .active>a:hover, .tabs-left>.nav-tabs .active>a:focus {
border-color: #ddd transparent #ddd #ddd;
}
.nav-tabs>li.active>a, .nav-tabs>li.active>a:hover, .nav-tabs>li.active>a:focus {
}
.nav-tabs>li.active>a, .nav-tabs>li.active>a:hover, .nav-tabs>li.active>a:focus {
color: #555;
cursor: default;
background-color: #fff;
border: 1px solid #ddd;
border-bottom-color: transparent;
}
.nav-tabs>.active>a, .nav-tabs>.active>a:hover, .nav-tabs>.active>a:focus {
color: #555555;
background-color: #ffffff;
border: 1px solid #ddd;
border-bottom-color: transparent;
cursor: default;
}
答案 0 :(得分:1)
更改
ng-style="{'border-right-color':[currentData.colorCode]}">
到
ng-style="{'border-right-color':'{{currentData.colorCode}}'}">