Last active
August 9, 2023 05:37
-
-
Save fraserxu/e965101a4b26d8d41e58 to your computer and use it in GitHub Desktop.
Simple load more function for ng-repeat with limitTo filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set the default amount of items being displayed | |
$scope.limit= 5; | |
// loadMore function | |
$scope.loadMore = function() { | |
$scope.limit = $scope.items.length | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
i receiver the error message length is not defined
// 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
Can this js code be placed within <script> </script> and expected to work?