我试图在把手模板中指定数组中项目的索引:
{
people: [
{"name":"Yehuda Katz"},
{"name":"Luke"},
{"name":"Naomi"}
]
}
Run Code Online (Sandbox Code Playgroud)
使用这个:
<ul id="luke_should_be_here">
{{people[1].name}}
</ul>
Run Code Online (Sandbox Code Playgroud)
如果以上是不可能的,我如何编写一个可以访问数组中的spefic项的帮助器?
寻找一种方法来实现这一点:
{{#each someArray}}
{{../otherObject.[this]}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)
如何评估值,this然后将其作为对象的键引用otherObject?
如何使用变量而不是硬编码值访问车把模板内的数组元素?我需要做类似的事情:
{{#each condition in conditions}}
{{App.ops.[condition.op].name}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)
此刻并没有给我一个解析错误,但在运行时并没有给我任何回报.如果我做这样的事情:
{{App.ops.[1].name}}
Run Code Online (Sandbox Code Playgroud)
它有效,但它不是我想要的