i have read from the officia doc of emberjs 2.6 that :
Note: A route with a dynamic segment will only have its model hook called when it is entered via the URL. If the route is entered through a transition (e.g. when using the link-to Handlebars helper), then a model context is already provided and the hook is not executed. Routes without dynamic segments will always execute the model hook
so i tried something to see my self how its work :
post.js
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
alert("executed");
return this.get('store').findRecord('post', params.post_id);
}
});
index.hbs
post.title
index2.hbs
post.title
So when i open index.hbs and click on the link, the model hook is not called, and that what the doc confirm.
But When i open index2.hbs and click on the link, the model hook is called, even if its is a trinsition, not a link reload.
i can understand the second point because i give the route an id, so its use the id to fetch post from the store, but why is this point not described in the doc?
Aucun commentaire:
Enregistrer un commentaire