ember-cli-pagination icon indicating copy to clipboard operation
ember-cli-pagination copied to clipboard

Component pagination

Open emanuel-oprea opened this issue 10 years ago • 3 comments

I managed to make this work from a component by doing the following:

templates/products.hbs

{{products-pagination products=category.product_ids}}

templates/components/products-pagination.hbs

{{#each product in pagedProducts}}
  {{product.name}}
{{/each}}
{{page-numbers content=pagedProducts}}

components/products-pagination.hbs

import pagedArray from 'ember-cli-pagination/computed/paged-array';
export default Ember.Component.extend({
  searchProducts: function() {
    var products = this.get('products');
    return Ember.ArrayProxy.create({content: products});
  }.property('products'),
  queryParams: ["page", "perPage"],
  page: 1,
  perPage: 10,
  pagedProducts: pagedArray('searchProducts', {pageBinding: "page", perPageBinding: "perPage"}),
  totalPagesBinding: "pagedProducts.totalPages"
});

I don't know if this is the right way to do it, but it works for me (just wanted to share this).

emanuel-oprea avatar Jan 09 '15 14:01 emanuel-oprea

Interesting. Thanks for sharing.

broerse avatar Jan 09 '15 14:01 broerse

Thanks Emanuel. Did you run into any problems while doing this?

mharris717 avatar Jan 13 '15 14:01 mharris717

Hi, for what I'm doing now (an MVP) it works. If we decide to proceed further using ember, I'll have to investigate how to add the pagination params in the url.

emanuel-oprea avatar Jan 14 '15 09:01 emanuel-oprea