I would like to set the className:active selector by ng-class like so:
ng-class='{"className:active" : true}'
Asked
Active
Viewed 1,846 times
0

Zdenek Hatak
- 1,135
- 14
- 23

h. Oo
- 361
- 1
- 2
- 10
-
Don't think that you can/may do that. Please explain your use case, why would you want to do that? You could set the `.focus()`, then it would be the active element. – devqon Feb 08 '17 at 10:34
2 Answers
0
try this :
ng-class="{'active':true}"
for variable you can try
<!-- 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>

Community
- 1
- 1

Nitya Kumar
- 967
- 8
- 14
0
I guess you have to "fake" it by creating class that has exactly the same properties as your :active pseudo class.

Zdenek Hatak
- 1,135
- 14
- 23