PrimeNG: p-autoComplete not clearing value

I am using PrimeNG. I wrote the auto-fill code as follows

<p-autoComplete name="searchSuggestions" [(ngModel)]="suggestion" 
(completeMethod)="searchSuggestions($event)" [suggestions]="searchSuggestionsResult" field="field"></p-autoComplete>

      

I am clearing suggestion

in the method but not clearing the autocomplete input value. It only clears if I choose from suggestions.

this.suggestion = undefined;

      

+3


source to share


2 answers


Please update the version primeng

to "primeng": "^1.1.1"

, then it will work well.



0


source


Use the onClear () method and set your model values ​​= null.

==== HTML

(onClear)="clearValue()

      

== c



clearValue()
{
    this.suggestion = null;
}

      

This function will only be called when you clear all values ​​from the autocomplete list.

Hope it works!

0


source







All Articles