Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module("app").controller("billetController",function($scope,billetService)
- {
- var self = this;
- self.billets=[];
- $scope.allCandidates=[];
- $scope.aCandidates=[];
- $scope.totalItems=0;
- $scope.sortType = 'statutBillet'; // set the default sort type
- $scope.sortReverse = false; // set the default sort order
- getBillets();
- function getBillets(){
- billetService.getBillets()
- .then(
- function(d) {
- console.log(d);
- self.billets=d;
- $scope.totalItems = self.billets.length;
- $scope.$watch("currentPage", function() {
- console.log( $scope.currentPage);
- $scope.aCandidates =self.billets.slice(
- ($scope.currentPage - 1) * $scope.itemsPerPage,
- $scope.currentPage * $scope.itemsPerPage
- ); });
- },
- function(errResponse){
- console.error('Error while fetching ');
- }
- );
- }
- $scope.currentPage = 1;
- $scope.itemsPerPage = 50;
- function setPagingData(page,allCandidates) {
- var pagedData = allCandidates.toString().slice(
- (page - 1) * $scope.itemsPerPage,
- page * $scope.itemsPerPage
- );
- $scope.aCandidates = pagedData;
- }
- console.log($scope.allCandidates);
- }) ;
- <div ng-controller="billetController">
- <table class="table table-hover">
- <thead>
- <th >ID</th>
- <th>
- <a href="#" ng-click="sortType = 'statutBillet'; sortReverse = !sortReverse">
- Statut
- <span ng-show="sortType == 'statutBillet' && !sortReverse" class="fa fa-caret-down"></span>
- <span ng-show="sortType == 'statutBillet' && sortReverse" class="fa fa-caret-up"></span>
- </a></th>
- <th>Priorité</th>
- <th>Impact</th>
- <th>Resumé</th>
- <th>Date de création</th>
- </thead>
- <tbody>
- <tr ng-repeat="billet in aCandidates | orderBy:sortType:sortReverse">
- <td>{{ billet.idBillet }}</td>
- <td>{{ billet.statutBillet }}</td>
- <td>{{ billet.prioriteBillet }}</td>
- <td>{{ billet.impactBillet }}</td>
- <td>{{ billet.resumeBillet }}</td>
- <td>{{ billet.dateCreation | date:'yyyy-MM-dd HH:mm:ss' }}</td>
- </tr>
- </tbody>
- </table>
- <uib-pagination total-items="totalItems" ng-model="currentPage" items-per-page="itemsPerPage"></uib-pagination>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement