File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,19 @@ local template variable (here we called it "auto"), and binding that variable to
48
48
At this point, the autocomplete panel should be toggleable on focus and options should be selectable. But if we want
49
49
our options to filter when we type, we need to add a custom filter.
50
50
51
- You can filter the options in any way you want based on the text input. Here we will do a simple string test on the
52
- input value to see if it matches the option value. We already have access to the built-in ` valueChanges ` observable on
53
- the ` FormControl ` , so we can simply map the text input's values to the suggested options by passing them through this
54
- filter. The resulting observable (` filteredOptions ` ) can be added to the template in place of the ` options ` property
55
- using the ` async ` pipe.
51
+ You can filter the options in any way you like based on the text input* . Here we will perform a simple string test on
52
+ the option value to see if it matches the input value, starting from the option's first letter. We already have access
53
+ to the built-in ` valueChanges ` observable on the ` FormControl ` , so we can simply map the text input's values to the
54
+ suggested options by passing them through this filter. The resulting observable (` filteredOptions ` ) can be added to the
55
+ template in place of the ` options ` property using the ` async ` pipe.
56
56
57
57
Below we are also priming our value change stream with ` null ` so that the options are filtered by that value on init
58
58
(before there are any value changes).
59
59
60
+ * For optimal accessibility, you may want to consider adding text guidance on the page to explain filter criteria.
61
+ This is especially helpful for screenreader users if you're using a non-standard filter that doesn't limit matches
62
+ to the beginning of the string.
63
+
60
64
* my-comp.ts*
61
65
``` ts
62
66
class MyComp {
You can’t perform that action at this time.
0 commit comments