角度ng重复元素计数

Isu*_*uru 4 angularjs

<li ng-repeat="Item in Items">
        <div ng-switch="($index)==0">
            <div ng-switch-when="true">
                <a href="#"><   Previous</a>
            </div>
            <div ng-switch-when="false">
                <a href="#">{{$index}}</a>
            </div>
        </div>
    </li>
Run Code Online (Sandbox Code Playgroud)

我想获取Items的元素数,并希望为最后一项显示"Next>"

Cha*_*ani 12

像这样的东西

<li ng-repeat="Item in Items">
                <a ng-if="$first" href="#"><   Previous</a>
                <a ng-if="!$first && !$last" href="#">{{$index}}</a>
                <a ng-if="$last" href="#">Next ></a>
    </li>
Run Code Online (Sandbox Code Playgroud)

获得长度使用Items.length.如果有过滤器,它会变得更复杂.看到这篇SO帖子