File tree Expand file tree Collapse file tree 3 files changed +6
-4
lines changed
examples/autocomplete-overview Expand file tree Collapse file tree 3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,8 @@ export class AutocompleteDemo {
8888 }
8989
9090 filterStates ( val : string ) {
91- return val ? this . states . filter ( ( s ) => s . name . match ( new RegExp ( val , 'gi' ) ) ) : this . states ;
91+ return val ? this . states . filter ( s => new RegExp ( `^${ val } ` , 'gi' ) . test ( s . name ) )
92+ : this . states ;
9293 }
9394
9495}
Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ export class AutocompleteOverviewExample {
7171 }
7272
7373 filterStates ( val : string ) {
74- return val ? this . states . filter ( ( s ) => new RegExp ( val , 'gi' ) . test ( s ) ) : this . states ;
74+ return val ? this . states . filter ( s => new RegExp ( `^${ val } ` , 'gi' ) . test ( s ) )
75+ : this . states ;
7576 }
7677
7778}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ class MyComp {
7575 }
7676
7777 filter(val : string ): string [] {
78- return this .options .filter (option => new RegExp (val , ' gi' ).test (option ));
78+ return this .options .filter (option => new RegExp (` ^${ val } ` , ' gi' ).test (option ));
7979 }
8080}
8181```
@@ -134,7 +134,7 @@ class MyComp {
134134 }
135135
136136 filter(name : string ): User [] {
137- return this .options .filter (option => new RegExp (name , ' gi' ).test (option ));
137+ return this .options .filter (option => new RegExp (` ^${ name } ` , ' gi' ).test (option ));
138138 }
139139
140140 displayFn(user : User ): string {
You can’t perform that action at this time.
0 commit comments