mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: fix error when searching for special characters in the autocomplete demo (#5213)
Fixes regex special characters causing the autocomplete in the demo app to throw. Relates to #3373.
This commit is contained in:
committed by
Jeremy Elbourn
parent
0ea2533b80
commit
bdf028646f
@@ -88,8 +88,11 @@ export class AutocompleteDemo {
|
||||
}
|
||||
|
||||
filterStates(val: string) {
|
||||
return val ? this.states.filter(s => new RegExp(`^${val}`, 'gi').test(s.name))
|
||||
: this.states;
|
||||
}
|
||||
if (val) {
|
||||
const filterValue = val.toLowerCase();
|
||||
return this.states.filter(state => state.name.toLowerCase().startsWith(filterValue));
|
||||
}
|
||||
|
||||
return this.states;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user