Skip to content

Instantly share code, notes, and snippets.

@Mehmet-Erkan
Created March 15, 2018 14:08
Show Gist options
  • Save Mehmet-Erkan/087b6f5f0e004bff22dc73bbf03b4c34 to your computer and use it in GitHub Desktop.
Save Mehmet-Erkan/087b6f5f0e004bff22dc73bbf03b4c34 to your computer and use it in GitHub Desktop.
Filter an array by keyword
performFilter(filterBy: string) : IProduct[] {
filterBy = filterBy.toLocaleLowerCase();
return this.products.filter((product: IProduct) =>
product.productName.toLocaleLowerCase().indexOf(filterBy) != -1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment