Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <pagination class="pagination pagination-sm" items-per-page="itemsPerPage" total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()"></pagination>
  2. <table class="table table-hover">
  3. <tr>
  4. <th ng-repeat="key in keys" ng-click="sorting.predicate=key;">
  5. {{key}}
  6. </th>
  7. </tr>
  8.  
  9. <tr ng-repeat="row in data | startFrom:currentRow | orderBy:sorting.predicate:sorting.reverse | limitTo:itemsPerPage">
  10. <td ng-repeat="key in keys">
  11. {{row[key]}}
  12. </td>
  13. </tr>
  14. </table>
  15.  
  16. app.filter('startFrom', function () {
  17. return function (input, start) {
  18. start = +start;
  19. return input.slice(start);
  20. };
  21. });
  22.  
  23. $scope.data = [{
  24. "id": 0,
  25. "age": 30,
  26. "name": "Trina Pace",
  27. "gender": "female",
  28. "email": "trinapace@darwinium.com",
  29. "phone": "+1 (874) 414-2654"
  30. },etc..];
  31.  
  32. $scope.keys = Object.keys($scope.data[0]);
  33. $scope.totalItems = $scope.data.length;
  34. $scope.itemsPerPage = 25;
  35. $scope.currentPage = 1;
  36. $scope.currentRow = 0;
  37.  
  38. $scope.pageChanged = function () {
  39. $scope.currentRow = ($scope.currentPage - 1) * $scope.itemsPerPage;
  40. console.log('current row: ' + $scope.currentRow);
  41. console.log('items per page: ' + $scope.itemsPerPage);
  42. };
  43.  
  44. $scope.sorting = {predicate:'name',reverse:false};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement