0

I have a filter list which have 50 items. I just want to show 5 items and hide the rest to make a "Show More" button.

<ul>
    <li ng-repeat="a in filters.area">
         <input type="checkbox" ng-change="filter()" ng-model="a.checked"> {{ a.name }}
    </li>
</ul>
<span>SHOW MORE</span>
Upalr
  • 2,140
  • 2
  • 23
  • 33
Luan Cuba
  • 73
  • 6

3 Answers3

3

You can use the LimitTo in Angular

 <li ng-repeat="n in numbers | limitTo:numLimit">{{n}}</li>

Here is a sample JsFiddle

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
2

Use limitTo filter in AngularJS

{{ limitTo_expression | limitTo : limit : begin}}

Documentation

Something like this for your example:

<ul>
    <li ng-repeat="a in filters.area | limitTo: 5">
        <input type="checkbox" ng-change="filter()" ng-model="a.checked">
        {{a.name}}
    </li>
</ul>
<span>SHOW MORE</span>
Arg0n
  • 8,283
  • 2
  • 21
  • 38
1

Look at this thread and this demo plunker

<foo ng-repeat="item in items | limitTo: limit as results" n="{{item}}"></foo>
<button ng-hide="results.length === items.length" ng-click="limit = limit +2">show more...</button>
Community
  • 1
  • 1
optimus
  • 729
  • 2
  • 12
  • 36