Created
May 26, 2022 04:42
-
-
Save fireflysemantics/4ed30b502b4218111c06bfc383e5c812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'filter', | |
}) | |
export class FilterPipe implements PipeTransform { | |
transform(products: any[], query: string): any[] { | |
if (!products) return []; | |
if (!query || query.length == 0) return products; | |
return products.filter( | |
(p) => p.toLowerCase().indexOf(query.toLowerCase()) != -1 | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment