oferh / ng2-completer

Angular 2 autocomplete component
http://oferh.github.io/ng2-completer/
MIT License
347 stars 172 forks source link

dropdown list opens and closes when typing the first character #391

Open greenTea2Codes opened 6 years ago

greenTea2Codes commented 6 years ago

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!