2013-11-21 92 views
1

我想知道如果这是一个错误,或者如果我只是失去了一些东西......烬选择:选择计算别名VS值计算别名

上ember.Select您可以设置“选择”来一个计算的别名,它的作品。

selection: Em.computed.alias('parentView.controller.test3') 

您可以将'valueBinding'设置为一个路径,它可以工作。

valueBinding: 'parentView.controller.test2' 

但是,您不能将'值'设置为计算的别名,这是行不通的。

value: Em.computed.alias('parentView.controller.test') 

我已经包含了一个jsfiddle,它在最新的ember上演示了这一点。我在这里错过了什么吗?我以为我读过视图中的绑定将被默默弃用,我一直试图使用Em.computed.alias()来代替。

http://jsfiddle.net/3DzzZ/

回答

1

这是因为valueEmber.Select是计算性能,并要覆盖该计算财产打破了代码隐藏

/** 
In single selection mode (when `multiple` is `false`), value can be used to 
get the current selection's value or set the selection by it's value. 

It is not currently supported in multiple selection mode. 

@property value 
@type String 
@default null 
*/ 


value: Ember.computed(function(key, value) { 
    if (arguments.length === 2) { return value; } 
    var valuePath = get(this, 'optionValuePath').replace(/^content\.?/, ''); 
    return valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection'); 
}).property('selection'), 

selection只是一个无聊的财产

/** 
When `multiple` is `false`, the element of `content` that is currently 
selected, if any. 

When `multiple` is `true`, an array of such elements. 

@property selection 
@type Object or Array 
@default null 
*/ 


selection: null 
+0

值不是在上面列出的代码中调用或设置的函数,而是从字面上重写对象上的属性,在他的第三个麻烦的例子中它不会触及默认的实现。 – Kingpin2k