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 {
88
88
}
89
89
90
90
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 ;
92
93
}
93
94
94
95
}
Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ export class AutocompleteOverviewExample {
71
71
}
72
72
73
73
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 ;
75
76
}
76
77
77
78
}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ class MyComp {
75
75
}
76
76
77
77
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 ));
79
79
}
80
80
}
81
81
```
@@ -134,7 +134,7 @@ class MyComp {
134
134
}
135
135
136
136
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 ));
138
138
}
139
139
140
140
displayFn(user : User ): string {
You can’t perform that action at this time.
0 commit comments