1
具有應表示一個表,具有columns
和rows
的圖:Ember.js /把手嵌套每個迭代
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}}
。這是爲什麼?什麼是更好的方法?