0
我在使用每个块内的控制助手渲染出一个表时遇到了一些麻烦。我有这个烬应用:EmberJS - 在每个块内使用控制助手渲染出一个表
window.App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend({
rows: function(){
return [
Ember.Object.create({rowNum: 1}),
Ember.Object.create({rowNum: 2}),
Ember.Object.create({rowNum: 3})
]
}.property()
});
App.RowController = Ember.Controller.extend({
cols: function(){
return [
Ember.Object.create({colNum: 1}),
Ember.Object.create({colNum: 2}),
Ember.Object.create({colNum: 3})
]
}.property()
});
而这个模板:
<script type="text/x-handlebars" data-template-name="application">
<table>
<tr>
<th></th>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
</tr>
{{#each row in rows}}
{{#control "row" row}}
<tr>
<td>{{content.rowNum}}</td>
<td></td>
<td></td>
<td></td>
</tr>
{{/control}}
{{/each}}
</table>
<hr />
<table>
<tr>
<th></th>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
</tr>
{{#each row in rows}}
{{#control "row" row}}
<tr>
{{content.rowNum}}
</tr>
{{/control}}
{{/each}}
</table>
</script>
http://jsfiddle.net/charlieridley/AQ5gc/7/
第一个表渲染错误地显示为每次循环的最后一个值,但是当我删除 块正确呈现值。这是预期的行为?