我有一个系列
<li class=""><a href ng:click="a=1">A1</a></li>
<li class=""><a href ng:click="a=2">A2</a></li>
<li class=""><a href ng:click="a=3">A3</a></li>
有没有办法让我的班级改为<li class="current">
如果用户点击了三个<li>
元素中的任何一个?
答案 0 :(得分:1)
<li ng-class="{current: a == 1}"><a href ng:click="a=1">A1</a></li>
<li ng-class="{current: a == 2}"><a href ng:click="a=2">A2</a></li>
<li ng-class="{current: a == 3}"><a href ng:click="a=3">A3</a></li>
答案 1 :(得分:0)
这应该有效:
<li class="{{a==1 && 'current'}}"><a href ng:click="a=1">A1</a></li>
<li class="{{a==2 && 'current'}}"><a href ng:click="a=2">A2</a></li>
<li class="{{a==3 && 'current'}}"><a href ng:click="a=3">A3</a></li>