【发布时间】:2012-07-30 08:40:44
【问题描述】:
有一个应该代表一个表的视图,有columns 和rows:
App.ListView = Ember.View.extend({
templateName: 'list',
columns: ['t1', 't2', 't3'],
rows: [
{ t1: 'one', t2: 'two', t3: 'three' },
{ t1: 'two', t2: 'one', t3: 'seven' }
]
});
-分别是一个模板:
<table>
<thead>
<tr>
{{#each columns}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each rows}}
<tr>
{{#each ../columns}}
<td>does nothing: {{this}}</td>
{{/each}}
</tr>
{{/each}}
<tbody>
<table>
...也可以找到on jsfiddle:jsfiddle.net/nWnf2
当嵌套在行中时,我显然不能迭代列。 {{#each ../columns}} 根本没有被触发。这是为什么?有什么更好的方法?
【问题讨论】: