Skip to content

Instantly share code, notes, and snippets.

@jquery404
Last active September 12, 2018 08:22
Show Gist options
  • Save jquery404/4901a68f7d4ccf14e555ed0066ffd8aa to your computer and use it in GitHub Desktop.
Save jquery404/4901a68f7d4ccf14e555ed0066ffd8aa to your computer and use it in GitHub Desktop.
Angular and Bootstrap UI pagination
<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="&laquo;"
next-text="&raquo;">
</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