p-autocomplete catch clear/reset icon event

UI Components for Angular
Post Reply
dragon18
Posts: 14
Joined: 06 Sep 2017, 12:39

16 Mar 2018, 18:28

Hi everybody,
I'm using a p-autocomplete input:

Code: Select all

<p-autoComplete [(ngModel)]="myModel.input"  [suggestions]="results" 
      (completeMethod)="retrievelist$event)" field="name"  (onSelect)="selectSuggestion($event)"
      (onClear)="onClear()" emptyMessage="No result">
</p-autoComplete>
It works nicely but on selecting a result from droplist, a clear/reset icon (x) appears in input. Cliking it, the input is cleared but the event isn't catch by 'onClear' function. Deleting text from input the function is called correctly.
Is there a way to catch the click event on clear/reset button?
Thanks

dreadking
Posts: 1
Joined: 21 Jun 2018, 14:46

21 Jun 2018, 14:50

Is there any further information to this problem? I've stumbled upon the same issue (using an autocomplete with type 'search'), not knowing how to use this clear-event.

Thank you very much

vusan32
Posts: 1
Joined: 17 Jul 2019, 11:30

17 Jul 2019, 11:37

This worked for me

Code: Select all

import {AutoComplete} from 'primeng/autocomplete';


	@ViewChild('autocomplete')
	  ac: AutoComplete;

//under ngOnInit
		this.ac.el.nativeElement.onsearch = (event) => {
			console.log('cleared called')

		};

<p-autoComplete #autocomplete    ... other properties ...   </p-autoComplete>

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests