简体   繁体   中英

Get field value from field name in Meteor template

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}}

try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM