mercredi 18 avril 2018

Ember: How to get values of a file returned at Route->Model

import Route from '@ember/routing/route';

export default Route.extend({
    model() {
        return this.get('store').findAll('rentals');
    }
});

The code above returns all rentals, say, 10 objects. Now, I want to get first, or last, or even multiple, but can't. Tried:

return this.get('store').findAll('rentals')[0];
return this.get('store').findAll('rentals').get(0);
return this.get('store').findAll('rentals').firstObject;
return this.get('store').findAll('rentals').slice(0, 2);
return this.get('store').findAll('rentals').splice(0, 2);




Aucun commentaire:

Enregistrer un commentaire