Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- combineLatest(this.heroes$, this.searchFormControl.valueChanges)
- .subscribe(([changedHeroData, searchTerm]) => {
- const heroesArray = Object.values(changedHeroData);
- if (!searchTerm) {
- this.tableDataSource$.next(heroesArray);
- return;
- }
- const filteredResults = heroesArray.filter(hero => {
- return Object.values(hero).reduce((prev, curr) => {
- return prev || curr.toString().toLowerCase().includes(searchTerm.toLowerCase());
- }, false);
- });
- this.tableDataSource$.next(filteredResults);
- });
- this.searchFormControl.setValue('');
Add Comment
Please, Sign In to add comment