mercredi 4 mars 2015

Why doesn't my model hook receive no param?

Disclaimer: major newbie warning!


I've successfully set up a Rails backend/Ember front-end project following this tutorial.


My router is



import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
location: config.locationType
});

Router.map(function() {
this.resource('contacts', function() {
this.resource('contact', { path: '/:contact_id' });
});
});

export default Router;


Now I want to set up the possibility for finding only certain contacts based on the contact's lastName, so I followed the official docs for specifying query params.


I've modified my app/routes/contacts/index.js route so that it now looks like this:



import Ember from 'ember';

export default Ember.Route.extend({
queryParams: {
lastName: {
refreshModel: true
}
},
model: function(params) {
return this.store.findQuery('contact', params);
}
});


and app/controllers/contacts.js



import Ember from 'ember';

export default Ember.ArrayController.extend({

queryParams: ['lastName'],
lastName: null,

});


Unfortunately, params isn't filled, even when I specify a query param in the browser. More precisely, the params object looks like this:


enter image description here


which doesn't seem to contain anything interesting to me.


Yet, the query params information is somehow propagated to the view, so I feel slightly baffled. How can I have params be filled for the model hook in my route?





Aucun commentaire:

Enregistrer un commentaire