lundi 30 janvier 2017

Pagination in Ember using ember-cli-pagination

I'm trying to implement pagination on my project using ember-cli-pagination but it's not working. I have something like this in the controller:

import Ember from 'ember';
import pagedArray from 'ember-cli-pagination/computed/paged-array';

export default Ember.Controller.extend({
  // setup our query params 
  queryParams: ["page", "perPage"],

  // set default values, can cause problems if left out 
  // if value matches default, it won't display in the URL 
  page: 1,
  perPage: 10,

  // can be called anything, I've called it pagedContent 
  // remember to iterate over pagedContent in your template 
  pagedContent: pagedArray('car', {pageBinding: "page", perPageBinding: "perPage"}),

  // binding the property on the paged array 
  // to a property on the controller 
  totalPagesBinding: "pagedContent.totalPages"
});

In the documentation, where I've put car is named content. I imagine it's an array of the objects I want to paginate.

The project is here http://ift.tt/2jw2Jz9 at emberdata branch.

I would appreciate if anyone could help me out.




Aucun commentaire:

Enregistrer un commentaire