Binding ember.js单向绑定

Binding ember.js单向绑定,binding,ember.js,Binding,Ember.js,尝试将视图中的值绑定到控制器中的值时,我遇到一些单向绑定问题: App.ApplicationController = Ember.Controller.extend({ value: 'my value' }); App.ApplicationView = Ember.View.extend({ templateName: 'application', willInsertElement: function() { console.log('will

尝试将视图中的值绑定到控制器中的值时,我遇到一些单向绑定问题:

App.ApplicationController = Ember.Controller.extend({
    value: 'my value'
});

App.ApplicationView = Ember.View.extend({
    templateName: 'application',

    willInsertElement: function() {
        console.log('will insert element');
        console.log('value from controller > ', this.get('controller').get('value'));
        console.log('value > ', this.get('value'));
        console.log('completeValue > ', this.get('completeValue'));
    },

    valueBinding: Ember.Binding.oneWay('controller.value'),
    completeValueBinding: Ember.Binding.oneWay('App.ApplicationController.value')
});

“value>”返回正确的值,但“completeValue>”返回未定义的值(请参见jsFiddle).

您引用的是类
应用程序控制器
而不是实际实例

您已经通过视图的
controller
属性访问了
ApplicationController
实例,因此只需将其用于绑定:

valueBinding: Ember.Binding.oneWay('controller.value'),
completeValueBinding: Ember.Binding.oneWay('controller.value')

这使得它与
valueBinding

相同
valueBinding
completeValueBinding
之间有什么区别?