부모 (arrayController) 속성을 자식 (itemController)에 바인딩하려고합니다. 바인딩은 this.set ('foo', property)와 같은 childController에서 프라퍼티를 설정할 때만 계산 된 속성을 사용하여 작동합니다.어린이 컨트롤러 바인딩 속성
App.IndexController = Ember.ArrayController.extend({
numberOfAllLetters: (function() {
return this.getEach('lettersNo').reduce(function(prev, curr){
return prev + curr
});
}).property('@each.lettersNo'),
numberOfAllLetters2: (function() {
return this.getEach('length2').reduce(function(prev, curr) {
return prev + curr;
})
}).property('@each.length2')
});
// child
App.WordController = Ember.ObjectController.extend({
lettersNo: (function() {
length = this.get('name').length;
// why only through 'set' the arrayController binds properly?
// if in parent controller I bind to '@each.length2', it works good. but why?
this.set('length2', length);
return this.get('name').length;
}).property('name')
});
핸들 : 내가 뭔가를 놓친 거지 궁금하고 있어요
<script type="text/x-handlebars" data-template-name="index">
<ul>
{{#each word in model itemController="word"}}
<li>{{input value=word.name}}</li> letters:
{{word.lettersNo}}
{{/each}}
</ul>
Total letters:{{numberOfAllLetters}} <br/> <!-- doesnt work -->
Total letters2:{{numberOfAllLetters2}} <br/> <!-- works -->
</script>
난 아이의 템플릿, 자녀의 컨트롤러에 동일한 속성을 사용하여 부모의 컨트롤러에 바인더 제본 할 수없는 이유. http://jsfiddle.net/licancabur/de1k7jcb/
답변 해 주셔서 감사합니다. 매우 재미 있습니다. Ember.ArrayController와 Ember.ObjectController에 대한 정보를 찾으려고 노력했습니다 .Controller deprecations - 당신은 그것에 대해 읽은 곳을 쓸 수 있습니까? –
https://gist.github.com/Kuzirashi/7f6016e426005146f593 –