[
{name:"foo",last:"bar",age:100},
{name:"baz",last:"foobar",age:200},
]
有没有办法如何使用{{#each}}帮助器将其迭代到流星模板
<template name='boo'>
{{#each objectInArray}}
<span> {{namehere}} </span>
{{/each}}
</template>
答案 0 :(得分:1)
你可以这样做:
<template name="boo">
{{#each objectInArray}}
<span> {{foo}} </span>
<span> {{last}} </span>
<span> {{age}} </span>
{{/each}}
</template>
Template.boo.objectInArray = function() {
return [
{name:"foo",last:"bar",age:100},
{name:"baz",last:"foobar",age:200},
]
}