<过时的>关于Ember.js指南中的{{linkTo}} [英] <OUTDATED> about {{linkTo}} in Ember.js Guide

查看:46
本文介绍了<过时的>关于Ember.js指南中的{{linkTo}}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 Ember.js模板的指南.在上述链接的第一个示例的车把部分中,他们使用了

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}}

但我认为

{{#linkTo posts.post}}

会工作的.

为什么我需要第二个参数"post"?

我读了解释:

如果路线具有动态路段,则代表该路段的模型部分.默认情况下,Ember.js将用值替换该段对象的id属性的值.

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.

推荐答案

#linkTo 帮助器具有三个参数.

The #linkTo helper takes three parameters.

  1. 您的情况下的路线 posts.post
  2. 上下文,这里是您在循环中引用的特定 post 对象
  3. 选项哈希(当前支持 title )

因为 posts.post 路线是动态路线,例如它可能是帖子集合中的一个,我们必须为 #linkTo 帮助器提供您要链接到的特定帖子.

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.

这篇关于<过时的>关于Ember.js指南中的{{linkTo}}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆