如何使用Meteor Spacebars {{#each}}块迭代一系列字符串?

Mis*_*sha 1 javascript arrays meteor spacebars

我有一个Mongo.Collection,它包含'Question'对象.每个'问题'都有一个叫做的属性choices

Questions.insert({
    text: 'What is the capitol of the US?',
    choices: [
    "Washington D.C.",
    "Houston",
    "New York City",
    "Los Angeles"
    ],
    correctChoice: 0,
    date: new Date().toDateString()
});
Run Code Online (Sandbox Code Playgroud)

在我的模板中,我有这个:

<div class="question">
    <div class="question-content">
        <p>{{text}}</p>
        <ul>
            {{#each choices}}
            //?????????
            {{/each}}
        </ul>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

为了使包含适当选择的列表项的无序列表更受欢迎,我应该放置什么而不是问号?

谢谢你的阅读.对不起,如果这很容易.我在Meteor还是一个小小的菜鸟.=)

Dav*_*don 9

看起来这是在评论中解决的,但是这个问题有一个答案:你应该this在当前上下文是原始的情况下使用.

<div class="question">
  <div class="question-content">
    <p>{{text}}</p>
    <ul>
      {{#each choices}}
        <li>{{this}}</li>
      {{/each}}
    </ul>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)