Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Meteor空格键{{{each}}块迭代字符串数组?_Javascript_Arrays_Meteor_Spacebars - Fatal编程技术网

Javascript 如何使用Meteor空格键{{{each}}块迭代字符串数组?

Javascript 如何使用Meteor空格键{{{each}}块迭代字符串数组?,javascript,arrays,meteor,spacebars,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

我有一个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()
});
在我的模板中,我有以下内容:

<div class="question">
    <div class="question-content">
        <p>{{text}}</p>
        <ul>
            {{#each choices}}
            //?????????
            {{/each}}
        </ul>
    </div>
</div>

{{text}}

    {{{#每个选项} //????????? {{/每个}}
为了让无序列表中包含适当选项的列表项更受欢迎,我应该用什么来代替问号


谢谢你的阅读。对不起,如果这很简单的话。我对流星还是有点不在行

这看起来像是在注释中解决的,但是这个问题有一个答案:如果当前上下文是原语,则应该使用
this

<div class="question">
  <div class="question-content">
    <p>{{text}}</p>
    <ul>
      {{#each choices}}
        <li>{{this}}</li>
      {{/each}}
    </ul>
  </div>
</div>

{{text}}

    {{{#每个选项}
  • {{this}}
  • {{/每个}}

这看起来像是在注释中解决的,但是这个问题有一个答案:在当前上下文是原语的情况下,应该使用
this

<div class="question">
  <div class="question-content">
    <p>{{text}}</p>
    <ul>
      {{#each choices}}
        <li>{{this}}</li>
      {{/each}}
    </ul>
  </div>
</div>

{{text}}

    {{{#每个选项}
  • {{this}}
  • {{/每个}}
给你:Derp.=)我知道事情会这么简单。谢谢给你:Derp.=)我知道事情会这么简单。谢谢