6

我想创建一个带有标签的帖子模型,并且能够显示每个帖子的所有标签。你知道最好的方法吗??

我试过这个

<template name='postsLists'>
  {{#each post}}
    {{> postDetails }}
  {{/each}}
</template>


<template name='postDetails'>
  title: {{title}}
  {{#each tag}}
    {{tag}}
  {{/each}}
</template>
4

2 回答 2

10

您需要使用this关键字从数组中获取值:

<template name='postDetails'>
  title: {{title}}
  {{#each tag}}
    {{this}}
  {{/each}}
</template>
于 2013-05-22T19:45:29.740 回答
2

此代码不起作用:

{{#each tag}}
  {{tag}}
{{/each}}

因为这里的“标签”指的是列表和该列表中的元素。尝试:

{{#each tags}}
  {{tag}}
{{/each}}
于 2013-01-08T16:26:51.370 回答