标签:
ng-class是AngularJS预设的一个指令,用于动态自定义dom元素的css class name.
<button ng-class="{{blue}}">button1</button>
$sc.blue = "blue";
.blue{
background-color: blue;
}
2:字符串数组形式。
<button ng-class="{true: ‘red‘}[isRed]">button2</button>
$sc.isRed = true;
.red{
background-color: red;
}
3:对象key/value处理。
<button ng-class="{‘yellow‘: isYellow, ‘color‘: color}">button3</button>
$sc.isYellow = true;
$sc.color = true;
.yellow{
background-color: yellow;
}
.color{
color: #ccc;
}
标签:
原文地址:http://www.cnblogs.com/zhx1991/p/4584078.html