作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要调用 ItemController 中的函数/或从 ArrayController 设置子 ItemController 的新属性。
为了更好的画面
App.ProductsController = Ember.ArrayController.extend({
needs: ["product"],
itemController: 'product',
contentChanged: function() { //no idea how to initiate this, hence I use observes
// How do I access the children controllers from here?
// I had tried below, but not working:
// this.get("content").forEach(function(item) {
// item.doSomething();
// });
}.observes('content')
});
App.ProductController = Ember.ObjectController.extend({
doSomething: function() {
//supposed to do something
}
});
我还没有找到任何方法来做到这一点。
最佳答案
这应该是 arrayController 实例本身的 forEach 。 this.get("content")
这里返回未包装在 itemController 中的模型数组
this.forEach(function(item) {
item.doSomething();
});
关于javascript - 如何从 ArrayController 访问 ItemController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20096645/
我是一名优秀的程序员,十分优秀!