Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pagination class="pagination pagination-sm" items-per-page="itemsPerPage" total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()"></pagination>
- <table class="table table-hover">
- <tr>
- <th ng-repeat="key in keys" ng-click="sorting.predicate=key;">
- {{key}}
- </th>
- </tr>
- <tr ng-repeat="row in data | startFrom:currentRow | orderBy:sorting.predicate:sorting.reverse | limitTo:itemsPerPage">
- <td ng-repeat="key in keys">
- {{row[key]}}
- </td>
- </tr>
- </table>
- app.filter('startFrom', function () {
- return function (input, start) {
- start = +start;
- return input.slice(start);
- };
- });
- $scope.data = [{
- "id": 0,
- "age": 30,
- "name": "Trina Pace",
- "gender": "female",
- "email": "trinapace@darwinium.com",
- "phone": "+1 (874) 414-2654"
- },etc..];
- $scope.keys = Object.keys($scope.data[0]);
- $scope.totalItems = $scope.data.length;
- $scope.itemsPerPage = 25;
- $scope.currentPage = 1;
- $scope.currentRow = 0;
- $scope.pageChanged = function () {
- $scope.currentRow = ($scope.currentPage - 1) * $scope.itemsPerPage;
- console.log('current row: ' + $scope.currentRow);
- console.log('items per page: ' + $scope.itemsPerPage);
- };
- $scope.sorting = {predicate:'name',reverse:false};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement