1

我有一个文档 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"
              }
  ]
}
4

1 回答 1

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}}
于 2013-02-21T05:04:32.193 回答