我正在使用Angular ng-repeat,如下所示:
<ul>
<li ng-repeat="tab in tabs" ng-class="{ active:isSet($index) }" ng-click="setTab($index, tab)"> {{tab}} </li>
</ul>
但最终的HTML是这样的:
<ul>
<li ng-repeat="tab in tabs" ng-class="{ active:isSet($index) }" ng-click="setTab($index, tab)" class="ng-scope ng-binding"> First item </li>
<li ng-repeat="tab in tabs" ng-class="{ active:isSet($index) }" ng-click="setTab($index, tab)" class="ng-scope ng-binding"> Second item </li>
</ul>
Wheras我希望正确呈现$ index,如下所示:
<ul>
<li ng-repeat="tab in tabs" ng-class="{ active:isSet(0) }" ng-click="setTab(0, tab)" class="ng-scope ng-binding"> First item </li>
<li ng-repeat="tab in tabs" ng-class="{ active:isSet(1) }" ng-click="setTab(1, tab)" class="ng-scope ng-binding"> Second item </li>
</ul>
我做错了什么?