I'm reading guide of Ember.js templates. In the handlebar part of the first example of above link, they used
{{#linkTo posts.post post}}
but I thought
{{#linkTo posts.post}}
would work.
Why do I need second argument 'post'?
I read the explanation:
If the route has a dynamic segment, a model that represents the segment. By default, Ember.js will replace the segment with the value of the object's id property.
but I can't associate this explanation with question above.
In Ember Data, models are objects that represent the underlying data that your application presents to the user. Note that Ember Data models are a different concept than the model method on Routes, although they share the same name.
The store contains all of the data for records loaded from the server. It is also responsible for creating instances of Model that wrap the individual data for a record, so that they can be bound to in your Handlebars templates.
This is the core feature of the Ember. js. The router used for to translate URL into the series of templates and also it represents the state of an application. The Ember. js uses the HashChange event that helps to know change of route; this can be done by implementing HashLocation object.
The #linkTo
helper takes three parameters.
posts.post
post
object you are referring to in the looptitle
is supported)Because the posts.post
route is a dynamic route, e.g. it can be for one of a collection of posts, we must provide the #linkTo
helper with which particular post you are wanting to link to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With