Tanvi Shah
Tanvi Shah

Reputation: 507

How to create custom filtering using MatTableDataSource in angular 5?

In Angular material official website Angular Material Table it is mentioned that filterPredicate: ((data: T, filter: string) => boolean) will filter data based on a specific field. But don't know how to start. Is there any example is present for this.

Upvotes: 9

Views: 14648

Answers (1)

Pete
Pete

Reputation: 794

This answer seems to show how to use the filter predicate:

https://stackoverflow.com/a/50174938/6130716

It works like so:

this.dataSource.filterPredicate = (data: MyObject, filter: string) => {
  return data.property == filter;
};

this.dataSource.filter = myValue;

Upvotes: 15

Related Questions