答案 0 :(得分:0)
一种方法是在App.IndexController中添加一个观察者,如下所示:
App.IndexController = Ember.ObjectController.extend({
listBinding: 'model.val'
listContentChanged: function() {
// here the code, but, you won't know which one changed
}.observes('list.@each.content')
});
另一种方法是创建另一个控制器来表示列表中的每个元素:
App.MyController = Ember.ObjectController.extend({
contentChanged: function() {
// and here, you can access 'content', content will be each of
//the objects in the list array
}.observes('content.content')//we're observing 'content.content',
//the first one is the content of this controller, which is one
//of the elements of the list array, and the second 'content'
//would be the property you defined in each of the objects when you created them
});
然后,您需要更改模板中的循环,如下所示:
{{#each l in list itemController="my"}}
{{input value=l.content.content}}
{{/each}}
itemController ="我"指定数组中的每个元素都将创建MyController的实例。
希望这有帮助。