我正在尋找通過ng-if條件的第一個索引,它並不總是$index === 0
,並且無法使用$first
解決。AngularJS:使用ng-repeat在第一個元素上應用CSS類
這裏是我的代碼示例:
<div class="ticket-event" ng-if="!item.hidden" ng-repeat="item in ctrl.event.items">
<div class="title item" ng-class="{'active': $index === $first}"></div>
</div>
我想在item
第一次出現添加類。
但是,當通過第二行的項目索引不是從0開始,讓我們說5,$第一個指令不起作用 –