Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. angular.module("app").controller("billetController",function($scope,billetService)
  2. {
  3. var self = this;
  4. self.billets=[];
  5. $scope.allCandidates=[];
  6. $scope.aCandidates=[];
  7. $scope.totalItems=0;
  8. $scope.sortType = 'statutBillet'; // set the default sort type
  9. $scope.sortReverse = false; // set the default sort order
  10.  
  11.  
  12.  
  13. getBillets();
  14. function getBillets(){
  15. billetService.getBillets()
  16. .then(
  17. function(d) {
  18.  
  19. console.log(d);
  20. self.billets=d;
  21. $scope.totalItems = self.billets.length;
  22. $scope.$watch("currentPage", function() {
  23. console.log( $scope.currentPage);
  24.  
  25. $scope.aCandidates =self.billets.slice(
  26. ($scope.currentPage - 1) * $scope.itemsPerPage,
  27. $scope.currentPage * $scope.itemsPerPage
  28. ); });
  29.  
  30. },
  31. function(errResponse){
  32. console.error('Error while fetching ');
  33. }
  34. );
  35. }
  36.  
  37. $scope.currentPage = 1;
  38. $scope.itemsPerPage = 50;
  39.  
  40.  
  41. function setPagingData(page,allCandidates) {
  42. var pagedData = allCandidates.toString().slice(
  43. (page - 1) * $scope.itemsPerPage,
  44. page * $scope.itemsPerPage
  45. );
  46. $scope.aCandidates = pagedData;
  47. }
  48.  
  49. console.log($scope.allCandidates);
  50.  
  51. }) ;
  52.  
  53. <div ng-controller="billetController">
  54. <table class="table table-hover">
  55. <thead>
  56. <th >ID</th>
  57. <th>
  58. <a href="#" ng-click="sortType = 'statutBillet'; sortReverse = !sortReverse">
  59. Statut
  60. <span ng-show="sortType == 'statutBillet' && !sortReverse" class="fa fa-caret-down"></span>
  61. <span ng-show="sortType == 'statutBillet' && sortReverse" class="fa fa-caret-up"></span>
  62. </a></th>
  63. <th>Priorité</th>
  64. <th>Impact</th>
  65. <th>Resumé</th>
  66. <th>Date de création</th>
  67. </thead>
  68. <tbody>
  69. <tr ng-repeat="billet in aCandidates | orderBy:sortType:sortReverse">
  70. <td>{{ billet.idBillet }}</td>
  71. <td>{{ billet.statutBillet }}</td>
  72. <td>{{ billet.prioriteBillet }}</td>
  73. <td>{{ billet.impactBillet }}</td>
  74. <td>{{ billet.resumeBillet }}</td>
  75. <td>{{ billet.dateCreation | date:'yyyy-MM-dd HH:mm:ss' }}</td>
  76. </tr>
  77.  
  78. </tbody>
  79.  
  80. </table>
  81. <uib-pagination total-items="totalItems" ng-model="currentPage" items-per-page="itemsPerPage"></uib-pagination>
  82. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement