When you load a route via {{#link-to 'node' nodeModel}} in a template, the model hook does not get called in the route object. From what I've read, you can fetch the related models in the route's afterModel hook in this case.
// routes/node.js
import Ember from 'ember';
export default Ember.Route.extend({
afterModel: function(model) {
return this.store.find('relatedModel');
}
});
I've tried a number of variations on this, and nothing has worked. It seems afterModel needs to return the model that gets set on the controller's model property, not just any promise. So… what do I have to do? I need the template to wait until related models have loaded before it renders.
Aucun commentaire:
Enregistrer un commentaire