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 に答える