5

Right now, I am using primeng autocomplete dropdown and in this we don't have functionality of clear/reset.

When i selecting a result from droplist, a clear/reset icon (x) should appears in input and click on (x) it will clear the inputbox.

<p-autoComplete [(ngModel)]="text" [suggestions]="results" (completeMethod)="search($event)"
            [dropdown]="true"></p-autoComplete>

Anyone have any better solution for this.

user3342682
  • 147
  • 3
  • 11

3 Answers3

6

Just add type=search <p-autocomplete type="search" ...>

user721730
  • 438
  • 1
  • 7
  • 11
2
<p-autoComplete [(ngModel)]="text" [suggestions]="results" (completeMethod)="search($event)" [dropdown]="true"></p-autoComplete>
<i class="fa fa-reset" (click)="onClear()"></i>       

onClear(){
    this.text='';
}
Unheilig
  • 16,196
  • 193
  • 68
  • 98
vinod j
  • 83
  • 1
  • 12
0

You can use PrimeNg Chip. When an option is selected from the dropdown you can display the value in a chip which as a close button on it. This is the cleanest and most visually pleasant way to do it.