mercredi 5 octobre 2016

Ember-cli-pagination unable to print the remte aginated value in screen

cli-pagination(link) for pagination. It is working fine but i am unable to set the page value = 0 instead it is always 1.Then while trying to print the value in screen it always print the id the model and other values are always empty.Please find the code sample below.

model

export default DS.Model.extend({
id: DS.attr(),
name: DS.attr(),
status: DS.attr()
});

Controller

import Ember from 'ember';

export default Ember.Controller.extend({
queryParams: ["page", "perPage"],
page: 0,
perPage: 2,

//some actions
}); 

Route

import Ember from 'ember';
import RouteMixin from 'ember-cli-pagination/remote/route-mixin';

export default Ember.Route.extend(RouteMixin, {
   model: function(params) {
     params.paramMapping = {
  perPage: "size"};
return this.findPaged('book',params);
 },

setupController(controller, model) {
controller.set('model', model);
controller.set('books', model);
}

});

Template

<div class="row">
<div class="col-md-2">
    <h3>
        Books
    </h3>
</div>
</div>
<br/>


<h2></h2>
<h2></h2>
<h2></h2>
<h2>entered paged content</h2>




In the above code I am getting value for "book.id" but "book.name" & "book.status" is always empty even though getting value from backend.

Also by default "page" attribute is "1" but i want to set it "0" because back API will accept page number "0".

Could anyone please help me to resolve the above issue? Your help should be appreciable.




Aucun commentaire:

Enregistrer un commentaire