关于Ember.js指南中的{{linkTo}} [英] about {{linkTo}} in Ember.js Guide

查看:89
本文介绍了关于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 帮助需要三个参数。


  1. 在您的情况下,路由 posts.post

  2. 上下文,这里是您在循环中引用的特定 post 对象

  3. 支持选项哈希(目前标题

  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)

因为 posts.post route是一个动态路由,例如它可以是一个帖子的集合之一,我们必须提供您想要链接到的特定帖子的 #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天全站免登陆