Skip to content

Commit 6a5a6fb

Browse files
immanninotinayuangao
authored andcommitted
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.
1 parent 0a3cfa7 commit 6a5a6fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/material-examples/autocomplete-filter/autocomplete-filter-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class AutocompleteFilterExample {
3333

3434
filter(val: string): string[] {
3535
return this.options.filter(option =>
36-
option.toLowerCase().indexOf(val.toLowerCase()) === 0);
36+
option.toLowerCase().includes(val.toLowerCase()));
3737
}
3838

3939
}

0 commit comments

Comments
 (0)