我正在动态渲染表。
模板定义如下:
<template name="home">
<div class="row">
<div class="tblCSV">
<table class="table table-bordered table-hover table-striped">
<thead>
// Dynamic Header Row - Working
<tr>
{{#each columns}}
<th>
{{columnName}}
</th>
{{/each}}
</tr>
</thead>
// Dynamic Rows - Working
<tbody>
{{#each entries}}
{{> entry}}
{{/each}}
</tbody>
</table>
</div>
</div>
</template>
// if i try to iterate columns to print values per row, it prints field/column name instead it's value
<template name="entry">
<tr>
{{#each columns}}
// columnName is a mongodb field name, Not Working
<td>{{columnName}}</td> // This prints text of Column name itself instead its value
{{/each}}
</tr>
</template>
// If i use static column names, it prints all the column values perfectly
<template name="entry">
<tr>
<td>{{MyColumnName1}}</td> //This prints value of column name i.e. MyColumnValue
<td>{{MyColumnName2}}</td>
<td>{{MyColumnName3}}</td>
<td>{{MyColumnName4}}</td>
</tr>
</template>
模板脚本
Template.home.helpers({
entries: function () {
return Entry.find();
},
columns: function () {
return Column.find();
}
});
Template.entry.helpers({
columns: function () {
return Column.find();
}
});
这就是问题
这就是我想要的
随时询问您需要的任何信息。