作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个有两个 subview 的 Ember.View.ParentView。其中之一是 ContainerView。 ParentView 的另一个 subview 需要访问 ContainerView 的 subview 。
在 ContainerView 中,我尝试使用:
this.get('parentView').set('foo', this.get('childViews') )
希望这会将 ParentView 中的属性设置为 childView View 的数组。但是,在ParentView的第二个childView中,调用:
foo = this.get('parentView').get('foo')
返回类数组而不是实例。所以我现在正在尝试使用绑定(bind)。如何创建属性到类子属性的绑定(bind)?
最佳答案
使用 viewName
属性在父实例中设置 childViews 实例的名称(参见相关提交 here):
App.MyParentView = Ember.View.extend({
containerViewChilds: 'fooContainer.childViews',
aContainerView: Ember.ContainerView.extend({
// ...
}),
anotherView: Ember.View.extend({
containerViewChildsBinding: 'parentView.containerViewChilds'
// ...
})
});
App.MyParentView
模板:
{{view view.aContainerView viewName="fooContainer"}}
{{view view.anotherView}}
关于javascript - Ember 绑定(bind) : binding a property to its a child's property,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13423591/
我是一名优秀的程序员,十分优秀!