@johnunclesam wrote:
My code is here:
https://ember-twiddle.com/b894cec64a1d78a71e15b642d512cfcf
I need to use this computed property: "postsFiltered" with both Category and Search but when I change category on
clickCategory()
I need to reset the search text (if present).But then the computed property is already called? No?
And the same when I search something I need to reset category to
null
.postsFiltered: Ember.computed('category', 'search', function () { var posts = this.get('posts'); var search = this.get('search'); console.log('computed postsFiltered() with category: ' + this.get('category') + ', search: ' + search); return posts.filter((item) => item['categoryId'] === this.get('category')); // or this when I search, but I don't know how to do one or the other: // return posts.filter((item) => item['name'].includes(search)); }),
How to handle two properties in the same computed property?
Posts: 5
Participants: 3