< Pre...">

Angular Number of ng-repeat elements

<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>

I want to get the number of Items items and want to show "Next>" for the last item

+4
source share
1 answer

Something like that

<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>

To use the length Items.length. It becomes more complicated if there is a filter. See SO Post

+12
source

All Articles