0
我試圖計算表中的每一行。每個表格行都是一個新的集合。下面的代碼計算收集的總數並顯示它們。我如何將其更改爲顯示行號。使用{{#each}}顯示行號
路徑:calc.js
SalaryCalculator: function() {
return SalaryCalculator.find({});
},
SalaryCalculatorCount: function() {
return SalaryCalculator.find({}).count();
}
路徑:calc.html
{{#each SalaryCalculator}}
<tr>
<th scope="row">{{SalaryCalculatorCount}}</th>
<td>{{specialisation}}</td>
<td>{{subSpecialisation}}</td>
<td>{{positionTitle}}</td>
<td>{{yearsOfExperience}}</td>
<td>{{salary}}</td>
</tr>
{{/each}}
只需在模板中使用'@ index'。基本上重複http://stackoverflow.com/questions/24225071/how-can-i-get-the-index-of-an-array-in-a-meteor-template-each-loop –
簡單。謝謝。 – bp123