我想要使用emberjs模板呈现表格。该表应解决的列进行动态渲染:通过变量名称获取属性
<table>
{{#each item in this.items}}
<tr>
{{#each colName in this.columnNames}}
<td>{{item.[colName]}}</td>
{{/each}}
</tr>
{{/each}}
</table>
不过,我认为车把试图访问一个项目的属性colName
。我如何动态访问属性?
'this'是当前的上下文,因此,如您所说,它是一个项目。但是,您可以使用'with'更改模板中的作用域,这里是链接:http://emberjs.com/guides/templates/changing-scope/ – fanta