ember.js - Ember DS.RecordArray filter items -
i getting records in route model call, in 1 of components want show subset of records. doing calling models.filter(somefilter). problem filter returns array not ds.recordarray , when action causes model removed store, array not updated , component model not removed.
does know how either create filter returns ds.recordarray or convert existing array ds.recordarray.
// routes/index.js route.extend({ model() { return this.store.findall('user'); } }); //index.hbs {{some-component users=model}} //some-component.js component.extend({ filteredusers: ember.computed(function() { return this.get('users').filter(...); }) }); //some-component.hbs {{#each filteredusers |user| {{other-component user=user}} {{/each}}
filteredusers: ember.computed(function() { return this.get('users').filter(...); }) this executed once.so whenever users property changed filteredusers not recalculated not date. in case need introduce dependent property recalculated whenever dependent changed.
filteredusers: ember.computed('users',function() { return this.get('users').filter(...); })
Comments
Post a Comment