0

In my controller, I have a filtered array like

filteredPosts: Ember.computed.filterBy('model', 'foo', 'bar')

Is it possible that filteredPosts does not filter anything at all. I need this in case a user doesn't want to apply a filter and just wants to see all of the posts.

Cameron
  • 2,805
  • 3
  • 31
  • 45

1 Answers1

1

Then don't use Ember.computed.filterBy. If you don't want to filter use the array directly. Or to implement something like a wildcard build your own computed property:

filteredPosts: Ember.computed('model', 'bar', {
    get() {
        const filter = this.get('bar');
        const model = this.get('model');
        return filter === '*' ? model : model.filterBy('foo', bar);
    }
})

Basically Ember.computed.filterBy is just syntactic sugar around a few lines of code. If you want to modify this code, just write it yourself.

Lux
  • 17,835
  • 5
  • 43
  • 73