angularUtils icon indicating copy to clipboard operation
angularUtils copied to clipboard

Paginate nested elements

Open pratimachainani opened this issue 9 years ago • 1 comments

Hi,

I am trying to paginate over items which have been purchased through a certain time period. My goal is to display the items annotated by the date they have been purchased. Here is my code snippet,

<div class="date-purchased" ng-repeat="date in dates">
  <div class="items-purchased" dir-paginate="item in items[date] | itemsPerPage:pageSize" currentPage="currentPage">
  </div>
</div>

JSON data source:

{
"28-06-2016":[{itemId: "11", itemName: "item_11"},{itemId: "22", itemName: "item_22"}],
"22-06-2016":[{itemId: "101", itemName: "item_101"},{itemId: "202", itemName: "item_202"},{itemId: "303", itemName: "item_303"}],
"20-06-2016":[{itemId: "1001", itemName: "item_1001"}]
}

However, I end up seeing just the list of dates and the following error on console, "the itemsPerPage id argument does not match a registered pagination-id". Any help with this?

pratimachainani avatar Jun 28 '16 12:06 pratimachainani

Hi,

Since you will be using multiple pagination instances on a single page, you'll need to explicitly set the pagination-id to some unique value for each instance. This could be as simple as something like:

 <div class="items-purchased" dir-paginate="item in items[date] | itemsPerPage:pageSize" pagination-id="'instance' + $index" currentPage="currentPage">
  </div>

You would then have to use the same pagination id on the corresponding controls.

michaelbromley avatar Jul 07 '16 07:07 michaelbromley