Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primeng autocomplete no onSelect event on click

I expected that the PrimeNG AutoComplete component is emitting the (onSelect) event on and on Keyboard select. But it emits only Keyboard selection. While "[dropdown]=false"

The Example is very simple:

<p-autoComplete ... (onSelect)="onSelect()" ...>

...

onSelect(){
    console.log('select', this.suggestions);
  }

using: "primeng": "^6.1.4", "@angular/cli": "^6.2.3",

How do I catch a clicked selection on auto-complete suggestions?

Or even better: How can I achieve the "DropdownButton-click" behavior on "InputField-click"? Just to get rid of the dropdown button but keep the behavior.

EDIT:

Its similar to this case, but it doesnt helps me for the Angular way.

Primefaces Autocomplete - How to display dropdown items on click of input

like image 476
Gregor Sklorz Avatar asked Nov 20 '25 11:11

Gregor Sklorz


1 Answers

I confirm that this works for me on Angular8/PrimeNG8 ("primeng": "^8.0.0", "@angular/cli": "^8.3.25"). Both when selecting using the mouse or the keyboard: the onSelect gets triggered.

Make sure you pass the event as well:

<p-autoComplete ... (onSelect)="onSelect($event)" ...>

...

onSelect(event: any){
    console.log( event );
  }

Check "frosty"'s solution/stackblitz. That works.

like image 133
Pierre Avatar answered Nov 22 '25 01:11

Pierre