我用FireBase:的模型设置了路由
App.ApplicationRoute = Ember.Route.extend({
model: function() {
return EmberFire.Array.create({
ref: new Firebase("https://some-database.firebaseio.com/shape")
});
},
setupController: function(controller, model) {
controller.set('model', model);
}
});
在模板中,我用#each:在视图中显示每个数组对象
{#each controller}}
{{#view App.ColorView}}
<div>{{color}}</div>
{{/view}}
{{/each}}
在视图中,我喜欢点击操作来删除特定颜色:
App.ColorView = Ember.View.extend({
click: function() {
var theColor = this.get('content');
console.log(theColor);
}
});
目前,视图中显示了一个颜色列表,但当我试图访问属于该对象的模型属性时,我得到了"未定义"。是否需要进行其他设置?
您可以使用contentBinding
通过
{#each controller}}
{{#view App.ColorView contentBinding=this}}
<div>{{color}}</div>
{{/view}}
{{/each}}