문제

나는 다음과 같은 것을 가지고있다:

Epic = Ember.Object.extend({
    children:[],
    children_filtered: function(){        
        return this.get("children").filterProperty("archived",false);
    }.property("children"),
    init: function() {
      this._super();
      this.set("children", Ember.ArrayController.create({content:[]}) );
      this.set("stories",  Ember.ArrayController.create({content:[]}) );
    },
});

계산된 속성을 참고하십시오.

뷰에 필터링 된 어린이 를 사용하는 경우...

{{#each content.children_filtered }}
  hi
{{/each}}

내 응용 프로그램이 작동하지 않습니다.%

내가 뭘 잘못하고 있는지 어떤 아이디어?항목 목록과 필터링된 항목 목록이 있는 개체에 대해 따라야 할 더 나은 패턴이 있습니까?

도움이 되었습니까?

해결책

문제는 계산된 속성을 다음과 같이 설정해야 한다는 것입니다 cacheable.그렇지 않으면,그 값은 #each.논의가 있었습니다. cacheable 계산된 모든 속성의 기본값이어야 합니다.

children_filtered: function(){        
  return this.get("children").filterProperty("archived",false);
}.property("children").cacheable()

여기 예제가 있습니다.: http://jsfiddle.net/ebryn/9ZKSY/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top