I followed the demo and created a auto search for users.
In a form in the html:
<ng2-completer
[(ngModel)]="userSearchText"
[datasource]="userAccountsSource"
[minSearchLength]="2"
[ngModelOptions] = "{standalone: true}"
[inputClass] = "'form-control'"
[placeholder]= "'Search by name'"
(selected)="selectUserAccount($event)"
[selectOnClick]="true"
[clearSelected]="true"
[clearUnselected]="true"
In the component:
this.userAccountsSource = completerService.local(this.userData$, 'text', 'text');
The function selectUserAccount($event):
selectUserAccount(selected: CompleterItem) {
if ( selected ) {
// find and show the user data in another form
}
}
The completer works. However, after the initial focus, the dropdown list starts to display previous list whenever the user inputs the first character, and closes instantly.
After searching on the Internet with no success, I would like to ask how to prevent the dropdown list displaying when the search box is focused the second time and the first character is typed in.
I followed the demo and created a auto search for users.
In a form in the html: <ng2-completer [(ngModel)]="userSearchText" [datasource]="userAccountsSource" [minSearchLength]="2" [ngModelOptions] = "{standalone: true}" [inputClass] = "'form-control'" [placeholder]= "'Search by name'" (selected)="selectUserAccount($event)" [selectOnClick]="true" [clearSelected]="true" [clearUnselected]="true"
In the component: this.userAccountsSource = completerService.local(this.userData$, 'text', 'text');
The function selectUserAccount($event): selectUserAccount(selected: CompleterItem) { if ( selected ) { // find and show the user data in another form } }
The completer works. However, after the initial focus, the dropdown list starts to display previous list whenever the user inputs the first character, and closes instantly.
After searching on the Internet with no success, I would like to ask how to prevent the dropdown list displaying when the search box is focused the second time and the first character is typed in.
Thank you very much!