From 6a5a6fbdc65047576ce2ee285eab49bbdb59a8b9 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 13 Apr 2018 15:27:54 -0700 Subject: [PATCH] doc(autocomplete-filter): Update example to use Array.prototype.Inclues() (#10779) Was researching the Auto-complete feature to add it to a project and this little enhancement is more straightforward when dealing with more complex strings. Current example can't filter words with spaces. By using includes() it can filter full sentences. --- .../autocomplete-filter/autocomplete-filter-example.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material-examples/autocomplete-filter/autocomplete-filter-example.ts b/src/material-examples/autocomplete-filter/autocomplete-filter-example.ts index 089b6c98f8c..a324849a7f7 100644 --- a/src/material-examples/autocomplete-filter/autocomplete-filter-example.ts +++ b/src/material-examples/autocomplete-filter/autocomplete-filter-example.ts @@ -33,7 +33,7 @@ export class AutocompleteFilterExample { filter(val: string): string[] { return this.options.filter(option => - option.toLowerCase().indexOf(val.toLowerCase()) === 0); + option.toLowerCase().includes(val.toLowerCase())); } }