Neha Sohail
Neha Sohail

Reputation: 239

How to repeat over selected range in angularjs

How can I indicate which items in my array I want to display using ng-repeat? For example, I only want to repeat shots 4-6 in the shots array.

<div class="shot" ng-repeat="shot in shots"> 
    <!-- only show shots 4-6 in the array -->
    <a href="{{ shot.url }}"><img ng-src="{{ shot.thumbnail }}"></a>
</div>

Upvotes: 1

Views: 33

Answers (1)

georgeawg
georgeawg

Reputation: 48968

Use the limitTo filter:

<div class="shot" ng-repeat="shot in shots | limitTo : limit : begin"> 
    <!-- only show shots 4-6 in the array -->
    <a href="{{ shot.url }}"><img ng-src="{{ shot.thumbnail }}"></a>
</div>
$scope.limit = 6-4+1;
$scope.begin = 4;

For more information, see

Upvotes: 2

Related Questions