2013-11-21 4 views
1

나는 이것이 버그인지 궁금하네요 아니면 내가 당신이로 '선택'을 설정할 수 있습니다 ember.Select에 뭔가 ...타다 남은 선택 : 선택 계산 별칭 대 값 계산 별칭

를 누락하는 경우 계산 된 별칭 및 작동합니다.

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

경로에 'valueBinding'을 설정할 수 있으며 작동합니다.

valueBinding: 'parentView.controller.test2' 

그러나 '값'을 계산 별칭으로 설정할 수는 있지만 작동하지 않습니다.

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

필자는 가장 최근에이를 증명하는 jsfiddle을 포함 시켰습니다. 내가 여기서 뭔가를 놓치고 있니? 나는보기에서 바인딩이 조용히 사용되지 않을 것이고 Em.computed.alias()를 대신 사용하려고 시도했다고 읽었습니다.

http://jsfiddle.net/3DzzZ/

답변

1

Ember.Selectvalue는 계산 된 속성입니다 때문입니다, 당신은 계산 된 속성이 selection 반면

/** 
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'), 

그냥 지루한 속성입니다 코드 숨김을 깨는 것을 재정의

/** 
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

value는 위에 나열된 코드에서 호출되거나 설정되는 함수가 아니며 문자 그대로 무시합니다. 객체의 속성이므로 세 번째 번잡한 예제에서 기본 구현을 만지지는 않습니다. – Kingpin2k