从Meteor模板中的字段名称中获取字段值

时间:2022-11-15 19:43:27

I have two variables in my template rows and fields holding the documents and the field names in the collection, respectively.

我的模板行和字段中有两个变量,分别包含集合中的文档和字段名称。

I print it with

我用它打印

{{#each rows}}
  <tr>
    {{#each fields}}
      <td>{{name}}</td>
    {{/each}}
  </tr>
{{/each}}

but right now it just prints the field names instead of the actual values in the documents.

但是现在它只打印字段名称而不是文档中的实际值。

I want to obtain something similar to

我想获得类似的东西

{{#each rows}}
  <tr>
    <td>{{age}}</td>
    <td>{{height}}</td>
    ...
  </tr>
{{/each}}

1 个解决方案

#1


0  

try

{{#each rows}}
  <tr>
    {{#each fields}}
      <td>{{../name}}</td>
    {{/each}}
  </tr>
{{/each}}

#1


0  

try

{{#each rows}}
  <tr>
    {{#each fields}}
      <td>{{../name}}</td>
    {{/each}}
  </tr>
{{/each}}