我在meteor中有一个包含循环的模板。 {{text}}
是我正在循环的。 {{id}}
来自模板上下文,在循环中无法访问。如何将{{id}}
传递到循环的数据上下文中?
<template name="label>
{{#each label_set}}
{{text}} {{id}}
{{/each}}
</template>
答案 0 :(得分:3)
如果id
位于父上下文中,您可以使用each
从../
中访问它,如下所示:
<template name="label">
{{#each label_set}}
{{text}} {{../id}}
{{/each}}
</template>