I use this directive, iterating over an array \"myArr\", filtering for a few conditions.
Use ng-if
instead of ng-show
.
Unlike ng-show
, falsey ng-if
removes the element from the DOM.
EDIT:
Also, you can, in fact, use limitTo
filter, which would make your code much cleaner:
<div ng-init="limit = 2">
<foo ng-repeat="item in items | limitTo: limit as results"></foo>
</div>
<button ng-hide="results.length === items.length"
ng-click="limit = limit +2">show more...</button>
plunker