1

[
  {name:"foo",last:"bar",age:100},
  {name:"baz",last:"foobar",age:200},
]

Is there a way on how to iterate that to a meteor template using {{#each}} helper like

<template name='boo'>
  {{#each objectInArray}}
    <span> {{namehere}} </span>
  {{/each}}
</template>
4

1 回答 1

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},
  ]
}
于 2014-05-27T02:41:17.110 回答