将数据传递给流星圈

时间:2015-03-11 23:00:39

标签: meteor

我在meteor中有一个包含循环的模板。 {{text}}是我正在循环的。 {{id}}来自模板上下文,在循环中无法访问。如何将{{id}}传递到循环的数据上下文中?

<template name="label>
    {{#each label_set}}
        {{text}} {{id}}
    {{/each}}
</template>

1 个答案:

答案 0 :(得分:3)

如果id位于父上下文中,您可以使用each../中访问它,如下所示:

<template name="label">
  {{#each label_set}}
    {{text}} {{../id}}
  {{/each}}
</template>

另见:A Guide to Meteor Templates & Data Contexts