Last active
September 12, 2018 08:22
-
-
Save jquery404/4901a68f7d4ccf14e555ed0066ffd8aa to your computer and use it in GitHub Desktop.
Angular and Bootstrap UI pagination
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
<div class="info"> | |
Showing {{entryLimit*(currentPage-1)+1}} to {{entryLimit*(currentPage-1)+entryLimit}} of {{totalItems}} entries | |
</div> | |
<div ng-repeat="data in filtered = (activity) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit"> | |
<td>{{entryLimit *(currentPage-1)+$index+1}}</td> | |
</div> | |
<div | |
pagination | |
ng-model="currentPage" | |
data-max-size="maxSize" | |
on-select-page="setPage(page)" | |
boundary-links="true" | |
total-items="filteredItems" | |
items-per-page="entryLimit" | |
class="pagination-small" | |
previous-text="«" | |
next-text="»"> | |
</div> | |
<script> | |
// define all these inside the controller | |
$scope.currentPage = 1; | |
$scope.entryLimit = 20; | |
$scope.maxSize = 5; | |
$scope.filteredItems = $scope.activity.length; | |
$scope.totalItems = $scope.activity.length; | |
// filter for startFrom | |
app.filter('startFrom', function() { | |
return function(input, start) { | |
if(input) { | |
start = +start; //parse to int | |
return input.slice(start); | |
} | |
return []; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment