Search code examples
angularjsangularjs-ng-repeat

dir-paginate in table with nested ng-repeat


I'm using dir-paginate in a table which is a populated from nested ng-repeat data. Tables are correctly populated but sorting and pagination when done in one table is resulting all remaining tables also. I used track by $index also, but not working.

   <div ng-repeat= "pData in parentData">
    {{PData.item}}

   <table>
   <thead>
   </thead>
   <tbody> 

   <tr dir-paginate="item in pData.appraisals|orderBy:sortKey:reverse|filter:GenericSearch|itemsPerPage 
:10" pagination-id="policyHolderAppraisals"

 <td>{{item.b}}</td>
 <td>{{item.a}}</td>

 </tbody>
 </table>
 </div>

Solution

  • Yes this can be done by using the pagination-id to uniquely identify and group each pagination control for sorting, filtering etc.

    e.g.

    <ul>
        <li dir-paginate="customer in customers | itemsPerPage: 10" pagination-id="cust">{{ customer.name }}</li>
    </ul>
    
    <dir-pagination-controls pagination-id="cust"></dir-pagination-controls>
    
    <ul>
        <li dir-paginate="branch in branches | itemsPerPage: 10" pagination-id="branch">{{ customer.name }}</li>
    </ul>
    
    <dir-pagination-controls pagination-id="branch"></dir-pagination-controls>
    

    More information can be found here https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination#multiple-pagination-instances-on-one-page