-1

I want to filter an object and made this:

filteredList() {
      return this.messages.filter(message => {
        return message.number.toLowerCase().includes(this.search.toLowerCase())      
      })
    }

But this method works only for number in message. What if I want to search the value in whole object?

Andrew
  • 701
  • 1
  • 8
  • 19

1 Answers1

1

Assuming you mean searching for a string in all member variables you can just use an or operator to search different fields like return message.number.contains(x) || message.content.contains(x);

Also, have a look at this answer that uses a loop to iterate over properties of a variable. You could return true for each property that contains the search string