0

I m working with angularJS and php backend, and I have a long table, and I tried to put pagination to show only five line in every page. The problem is that I I have succeeded showing just five items but I can't see the pagination bar to navigate between pages. where is the problem please!

app.js

app.controller('AdminCtrl', function($scope, $http,$state){

      $scope.loadItem = function(){ 
              $http.get("http://localhost/deb/loadItem.php")  
           .success(function(data){   
                $scope.names = data; 
                $scope.currentPage = 1; //current page
                $scope.entryLimit = 5; //max no of items to display in a page
                $scope.filteredItems = $scope.names.length; //Initially for no filter  
                $scope.totalItems = $scope.names.length; 
           });
      }  
       $scope.setPage = function(pageNo) {
        $scope.currentPage = pageNo;
    };
    $scope.filter = function() {
        $timeout(function() { 
            $scope.filteredItems = $scope.filtered.length;
        }, 10);
    };
});

test.html

<div class="padding" ng-controller="AdminCtrl" ng-init="loadItem()" >
<table>
<tr>
    <th>code</th>
    <th>Client</th>
  </tr>
  <tr ng-repeat="x in filtered=(names|filter:search)|startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
    <td>{{x.Code}}</td>
    <td>{{x.Nom}}</td>
    </tr>
 </table>
        <div class="col-md-12" ng-show="filteredItems > 0">    
            <div pagination="" page="currentPage" 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>      
        </div>

Thanks in advance

Touria
  • 87
  • 7
  • Possible duplicate of [How to do paging in AngularJS?](https://stackoverflow.com/questions/10816073/how-to-do-paging-in-angularjs) – Vladimir Zdenek Jun 05 '17 at 13:45
  • @Vladimir , I tried the solution of the question you mentioned, but it doesn't work for me, I get this error when I try to implement it: Cannot read property 'slice' of undefined, and nothing appears – Touria Jun 05 '17 at 13:50
  • Obviously you cannot just copy and paste the answer, but it solves the exact same problem. You should be able to spot the differences and modify the code accordingly... – Vladimir Zdenek Jun 05 '17 at 14:01
  • Of course I have not made a copy paste Sir, but thers s a property which is not definded, also the code I put here must resolve my broblem bu it didn't because there s somthing wrong in what I do. And that's why I post my question here. Thank you – Touria Jun 05 '17 at 14:04

0 Answers0