我正在阅读 Ember.js templates 的指南.在上面链接的第一个示例的 Handlebars 部分,他们使用了
{{#linkTo posts.post post}}
但我想
{{#linkTo posts.post}}
会工作。
为什么我需要第二个参数“post”?
我读了解释:
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.
但我无法将这种解释与上述问题联系起来。
最佳答案
#linkTo
helper 需要三个参数。
posts.post
post
您在循环中引用的对象 title
)因为
posts.post
路线是动态路线,例如它可以是一个帖子的集合,我们必须提供#linkTo
您要链接到哪个特定帖子的助手。
关于ember.js - <OUTDATED> 关于 Ember.js 指南中的 {{linkTo}},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14453976/