I\'m trying to filter my array data on a table from Angular with the package w-ng5, but it\'s searching and it doesn\'t find nothing (blank list). This is the s
You can create a filter function that is called whenever your filter string changes.
The code will look something like this:
isMatch(item) {
if (item instanceof Object) {
return Object.keys(item).some((k) => this.isMatch(item[k]));
} else {
return item.toString().indexOf(this.filterString) > -1
}
}
This will iterate through the object recursively, and look for any matches. While it's not necessary (seeing as your object structure is flat), it could be useful if your structure ever changes. Bear in mind it's case sensitive as it stands
You then need to create a function that calls it, like so:
onFilterChange() {
this.filtered = this.invoices.filter((invoice) => this.isMatch(invoice));
}
And amend your input so that it refilters any time that the search string is changed
Here is a Stackblitz demo