나는 Phone
모델을 가지고 있습니다.ArrayController 캐싱 및 워킹
cachePhones : function() {
this.set('phones', this.Phone.find());
},
을 그리고 난 가능한 휴대폰이있는 국가를 얻을 :
getCountries : function() {
var phones = this.get('phones.content');
var countries = new this.dataSet(), country;
console.log('phones=%o', phones.length);
for (var index = 0, length = phones.length; index < length; index++) {
country = phones[index].record.get('country');
console.log('Adding %o', country);
countries.add(country, true);
}
console.log('countries=%o', countries.keys());
return countries.keys();
},
을
I (dataSet
자바 스크립트 단지 일련의 구현입니다) 내 응용 프로그램의 모든 전화를 캐시 할 이것이 올바른 길을 걷는 지 확신 할 수 없음 ArrayController
:
- 나는 실제로
content
에 액세스해야하나요? - 정말로
record
에 액세스해야하나요?
엠버 내부에서 내 방식을 해킹하는 것처럼 느껴집니다. 나는이 전에 시도했다 :
var phones = this.get('phones');
var countries = new this.dataSet(), country;
for (var index = 0, length = phones.length; index < length; index++) {
country = phones[index].country;
countries.add(country, true);
}
그러나 그것은 전혀 작동하지 않았다. ArrayController
을 걷는 표준 방법은 무엇입니까?
Ember.Set.create();를 사용할 수 있습니다. new this.dataSet(); 대신. Ember는 자신 만의 Set 구현을 가지고 있습니다.) –
감사합니다. – dangonfast