Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<OUTDATED> about {{linkTo}} in Ember.js Guide

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.

like image 726
synthresin Avatar asked Jan 22 '13 08:01

synthresin


People also ask

WHAT IS models in Ember JS?

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.

What is store in Ember JS?

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.

What is route in Ember?

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.


1 Answers

The #linkTo helper takes three parameters.

  1. The route, in your case posts.post
  2. The context, here it is the particular post object you are referring to in the loop
  3. An options hash (currently title 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.

like image 82
Bradley Priest Avatar answered Sep 18 '22 12:09

Bradley Priest