在我的ng-repeat
中,我需要根据DOM
状态切换active
。
我试过这样,但不适合我:
<ul>
<li ng-click="activate(item)" ng-repeat="item in items" ng-class="{active : active == item}">
<span ng-if="item==active">
<span>{{item}}</span><!-- when active nested under span -->
</span>
<!-- else without nesting the span -->
<span ng-if="item== !active">{{item}}</span> //this is not working
</li>
</ul>
答案 0 :(得分:2)
将您的上一个ng-if
语句替换为此语句(您刚刚语法错误):
<span ng-if="item !== active">{{item}}</span>
您的active
变量不是布尔值,因此您无法在语句中切换它。