Angular set:ng类的CSS主动选择器

时间:2017-02-08 10:19:45

标签: angularjs ng-class

我想通过ng-class设置className:active选择器,如下所示: ng-class='{"className:active" : true}'

2 个答案:

答案 0 :(得分:0)

试试这个:

<!-- add a class to the first item -->
<ul>
    <li ng-class="{ 'text-success': $first }" ng-repeat="item in items">{{ item.name }}</li>
</ul>

<!-- add a class to the last item -->
<ul>
    <li ng-class="{ 'text-danger': $last }" ng-repeat="item in items">{{ item.name }}</li>
</ul>

<!-- add a class to the even items and a different class to the odd items -->
<ul>
    <li ng-class="{ 'text-info': $even, 'text-danger': $odd }" ng-repeat="item in items">{{ item.name }}</li>
</ul>

您可以尝试变量

      A         B         C         D         E         F
    ------------------------------------------------------------
1   info    |           |        |        |       |
2   info    |           |        |        |       |
3   info    |           |        |        |       |
4   First   |           |        |        |       |
5           |  Data 1   |        |  Dates |       |   Data 2
6           |           |        |        |       |
7           |   Data    |        |  Date  |       |   Data
8           |   Data    |        |  Date  |       |   Data
9           |   Data    |        |  Date  |       |   Data
10          |           |        |        |       |
11          | Number dts|        |   3    |       |
12  Last    |           |        |

for more options

答案 1 :(得分:0)

我猜你必须通过创建与你的:active伪类具有完全相同属性的类来“伪造”它。