-
-
Save qalqi/0fbadbdece7c2510f0fe to your computer and use it in GitHub Desktop.
Load More Toggled to Load Less
This file contains 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 | |
var defaultvalue = 3; | |
$scope.limit= defaultvalue; | |
$scope.ismore = false; | |
// loadMore function | |
$scope.loadMore = function() { | |
$scope.limit = $scope.items.length; | |
$scope.ismore = true; | |
} | |
$scope.loadLess = function() { | |
$scope.limit= defaultvalue; | |
$scope.ismore = false; | |
} |
This file contains 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()' ng-class="{ 'hidediv': ismore }">More</button> | |
<button ng-click='loadLess()' ng-class="{ 'hidediv': !ismore }">Less</button> | |
</li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment