Skip to content

Instantly share code, notes, and snippets.

@fraserxu
Last active August 9, 2023 05:37
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save fraserxu/e965101a4b26d8d41e58 to your computer and use it in GitHub Desktop.
Save fraserxu/e965101a4b26d8d41e58 to your computer and use it in GitHub Desktop.
Simple load more function for ng-repeat with limitTo filter
// set the default amount of items being displayed
$scope.limit= 5;
// loadMore function
$scope.loadMore = function() {
$scope.limit = $scope.items.length
}
<ul class="lists">
<li ng-repeat="item in items | limitTo:limit">
<span>{{item.name}}</span>
</li>
<li>
<button ng-click='loadMore()'>Load More</button>
</li>
</ul>
@artforlife
Copy link

Can this js code be placed within <script> </script> and expected to work?

@shabirullah
Copy link

i receiver the error message length is not defined

@ssuryar
Copy link

ssuryar commented Nov 21, 2017

// set the default amount of items being displayed
$scope.limit= 5;

// loadMore function
$scope.loadMore = function() {
  $scope.limit =   $scope.limit + 5;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment