ng-filter
Demo
https://acme-company.github.io/ng-filter/
Installation
npm install ng-filter --save
Usage
App.Module.ts
;...;
App.Component.html
Filter First Name Last Name Birthdate {{ person.firstName }} {{ person.lastName }} {{ person.birthDate | date:'yyyy-MM-dd' }}
App.Component.ts
Add the FilterService to the providers array of your list component. The scope of FilterService should not be global because it tracks filter callbacks for a single list.
;;
Customizing Filter Functions
The filterService
provides a configure
method which accepts a configuration object. Each property of the configuration object can be set to a custom filter predicate.
The filter predicate has the following signature (where T is the item type from the array of items being filtered):
If the predicate returns true, then the item will be included in the filtered list. Otherwise, the item will be excluded.
For example, if the item type is a string:
Filter {{ item }}
filterService.configure;this.list = ;