我有一份文件RFQ和一个包含4个字段的子文档材料,并且可能有一个冗长的材料列表。我如何理想地在表格中显示子文档材料?
{
"_id" : 1,
"sdate" : ISODate("1924-12-03T05:00:00Z"),
"adate" : ISODate("2007-03-17T04:00:00Z"),
"materials" : [
{
"award" : "W.W. McDowellAward",
"year" : 1967,
"by" : "IEEE Computer Society"
},
{
"award" : "National Medal of Science",
"year" : 1975,
"by" : "National Science Foundation"
},
{
"award" : "Turing Award",
"year" : 1977,
"by" : "ACM"
},
{
"award" : "Draper Prize",
"year" : 1993,
"by" : "National Academy of Engineering"
}
]
}
答案 0 :(得分:4)
如何在单独的表格式结构中显示每个子文档?
像这样:
Template.hello.coll = function () {
return Coll.find({});
};
在你的html中,子文档可以显示如下:
主{{#each this.materials}}
帮助者中的 {{#each}}
。
{{#each coll}}
<tr>
<td> {{sdate}} </td>
<td> {{adate}} </td>
{{#each this.materials}}
<tr>
<td> {{award}} </td>
<td> {{year}} </td>
<td> {{by}} </td>
</tr>
{{/each}}
</tr>
{{/each}}