如果您不能更改属性名称,你可以使用一个计算的属性在你的模型对象,见http://jsfiddle.net/pangratz666/4ZQM8/:
把手:
<script type="text/x-handlebars" >
<ul>
{{#each App.controller}}
<li>{{actionProp}}</li>
{{/each}}
</ul>
</script>
的JavaScript:
App.Object = Ember.Object.extend({
actionProp: function() {
return this.get('action');
}.property('action')
});
App.controller = Ember.ArrayController.create({
content: [],
addObj: function(number) {
this.pushObject(App.Object.create({
action: number
}));
}
});
如果没有自定义模型对象,你可以使用在一个的CollectionView计算性能,见http://jsfiddle.net/pangratz666/r6XAc/:
把手:
<script type="text/x-handlebars" data-template-name="item" >
{{actionProp}}
</script>
JavaScript:
Ember.CollectionView.create({
contentBinding: 'App.controller',
itemViewClass: Ember.View.extend({
templateName: 'item',
actionProp: function(){
return this.getPath('content.action');
}.property()
})
}).append();
谢谢您的答复。不过,我仍然得到同样的错误。 – user1425025
嗯...这会工作(我*认为*)与香草把手至少...你可以使用'unbound'帮手,我想。 –
仍然失败... – user1425025