How would you filter the result of an ArrayProxy? I've tried slice, filter, rejectBy, all leading to no result in the view. I imagine it's because the data isn't available yet, but usage of then(...) hasn't panned out either. Any thoughts?
shownEvents: function(){
return Em.ArrayProxy.createWithMixins(Em.SortableMixin, {
content: this.get('shownUser.events'),
sortProperties: ['eventTime.startTime', 'eventTime.endTime'],
sortAscending: true
});
}.property("shownUser"),
I've reviewed quite a few articles similar to this but haven't found anything that quite works.
Can I add an additional computed property to an Ember ArrayProxy?
You can filter ArrayProxy by passing in a function to filter and returning true for the values that should pass the filtering test.
Something like:
App.IndexRoute = Ember.Route.extend({
model: function() {
return { pets: [ { type: 'dog'}, { type: 'cat'}, { type: 'fish'}] };
}
});
App.IndexController = Ember.ObjectController.extend({
myPets: function(){
return Em.ArrayProxy.createWithMixins(Em.SortableMixin, {
content: this.get('pets'),
sortProperties: ['type'],
sortAscending: true
}).filter(function(item){ return item.type.length === 3});
}.property("pets"),
});
Works here
Fill free to ignore this if you have tried this already ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With