Data binding 是否可以更改Emberjs对象属性在其';它被实例化了吗?

Data binding 是否可以更改Emberjs对象属性在其';它被实例化了吗?,data-binding,ember.js,Data Binding,Ember.js,这似乎不起作用 我真正想做的是将CollectionView的contentBinding从一个ArrayController更改为另一个。这是可能的还是坏主意?您必须以这种方式手动绑定: App.country.bind('presidentName', Em.Binding.from('App.president.name2')); 以下是JSFIDLE: 要了解更多关于绑定的信息,我建议查看旧的Sproutcore wiki:。请记住将SC前缀更改为Ember。使用Ember.bind

这似乎不起作用


我真正想做的是将CollectionView的contentBinding从一个ArrayController更改为另一个。这是可能的还是坏主意?

您必须以这种方式手动绑定:

App.country.bind('presidentName', Em.Binding.from('App.president.name2'));
以下是JSFIDLE:


要了解更多关于绑定的信息,我建议查看旧的Sproutcore wiki:。请记住将SC前缀更改为Ember。

使用
Ember.bind
,请参阅


谢谢你的回答,JSFIDLE链接不适用,所以我更新了它:谢谢你的回答!很高兴知道有多种方法可以设置/更改绑定!尽管在我现有的Ember.js应用程序中,没有必要按照您要求的方式手动更改绑定。我几乎总是更改控制器的实际内容,而不是创建新的绑定。您是否要求更改绑定的一般方法,或者您是否有特定的问题需要解决?
App.country.bind('presidentName', Em.Binding.from('App.president.name2'));
App = Em.Application.create()
App.president = Ember.Object.create({
    name: "Barack Obama",
    name2: "George Bush"
});

App.country = Ember.Object.create({
    // Ending a property with 'Binding' tells Ember to
    // create a binding to the presidentName property.
    presidentNameBinding: 'App.president.name'
});

App.someController = Em.Object.create({
    change: function() {
        Ember.bind(App, 'country.presidentName', 'App.president.name2');
    }
});​