【发布时间】:2014-01-02 21:52:27
【问题描述】:
我设置了一个简单的车把模板来显示来自模型记录的图像。以下按预期工作,并使用每个项目上的 imageURL 来显示图像。
{{#each this}}
<img {{bindAttr src="imageURL"}} >
{{/each}}
但是,我还想显示记录集中的第一张图像。经过How do I access an access array item by index in handlebars? 我没有运气添加了以下内容。
<img {{bindAttr src="this.0.imageURL"}} >
我也尝试了以下方法,但也没有运气。
{{#with this.[0]}}
<img {{bindAttr src="imageURL"}} >
{{/with}}
有什么想法吗?
著名:Ember 1.2.0、Handlebars 1.2.0、jQuery 1.10.2
【问题讨论】:
标签: javascript ember.js handlebars.js