[FIXED] PrimeNg DropDown – User can't clear the value


I’m implementing primeNg dropdown component in my Angular2 application.

<p-dropdown [options]="listCustomers_itm" placeholder="Selezionare" [(ngModel)]="Customer_itm" [ngModelOptions]="{standalone: true}" [style]="{'width':'225px'}" filter="filter"  (onChange)="onCustomerSelect($event.value)">

All works fine except one annoing thing:

Once time the user has selected an option, he can’t clear the selected value

Can you help me?


To fix this, I had to set a placeholder for the dropdown. The code I used is something like:


<p-dropdown ...

<button (click)="onButtonClick()"></button>


import { Dropdown } from "primeng/components/dropdown/dropdown";
dropDownThing: Dropdown;
onButtonClick() {
    this.dropDownThing.value = <someValueNotInTheDropdown'sList>;

When the code above is run without a placeholder, the currently-selected option remains selected.

When the code above is run with a placeholder, the dropdown’s value changes to the provided placeholder.

Answered By – Daniel Neel

Answer Checked By – Gilberto Lyons (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published