【发布时间】:2016-10-07 19:48:09
【问题描述】:
我正在使用 Meteor 并希望获取存储在用作内部数组的字段中的值。
当我运行查询(使用投影)时,我得到一条如下所示的记录:
{ "comments" : [ { "uid" : "1", "un" : "Sarah", "c" : "cc" }, { "uid" : "2", "un" : "Leo", "c" : "dd" } ] }
我需要在模板中显示数组中每条记录的“un”和“c”。 我试过了:
html:
<template name="allComments">
<ul>
{{#each allC}}
<li>{{un}}</li>
{{/each}}
</ul>
</template>
js:
Template.allComments.allC = function () {
//query that returns result as above
}
我也试过{{#with}},嵌套{{#each}}和嵌套模板,但它不起作用..
我怎样才能达到这个值?
非常感谢,莎拉。
【问题讨论】:
标签: javascript arrays mongodb meteor mongodb-query