Reputation: 170
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
Upvotes: 1
Views: 17617
Reputation: 2912
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.
Upvotes: 4
Reputation: 21762
I was able to get this to work in a stack blitz. The onSelect
works, as well as the completeMethod
works.
https://stackblitz.com/edit/angular-7komnz
Upvotes: 3