角度ng重复指数

时间:2015-08-25 15:45:39

标签: angularjs angularjs-ng-repeat

我正在使用Angular ng-repeat,如下所示:

<ul>
  <li ng-repeat="tab in tabs" ng-class="{ active:isSet($index) }" ng-click="setTab($index, tab)">&nbsp;{{tab}}&nbsp;</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">&nbsp;First item&nbsp;</li>
  <li ng-repeat="tab in tabs" ng-class="{ active:isSet($index) }" ng-click="setTab($index, tab)" class="ng-scope ng-binding">&nbsp;Second item&nbsp;</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">&nbsp;First item&nbsp;</li>
  <li ng-repeat="tab in tabs" ng-class="{ active:isSet(1) }" ng-click="setTab(1, tab)" class="ng-scope ng-binding">&nbsp;Second item&nbsp;</li>
</ul>

我做错了什么?

0 个答案:

没有答案