Using Ng-select clearable for only one field

Viewed 39

The following code is for two filters. However, when you click the clear button in one of the filters, both filters get cleared. Is there a way to use the [clearable] property so that only the clicked filter gets cleared?

<div class="filter-item" *ngFor="let datum of data" [ngClass]="{'select-filter': selectedItem && selectedItem?.label}'>

  <div class="title">
    <span>{{ datum.key }}</span>
  </div>

  <div class="select">
    <ng-select #select [placeholder]="'Select'" [items]="datum.data" [multiple]="false" 
     bindLabel="label" [(ngModel)]="datum.selectedItems" appendTo="body" 
     (change)="onChange($event, datum)">
    </ng-select>
  </div>

</div>
1 Answers

i think you did something wrong with config here is the latest ng-select example you can take a look in stackblitz

just click on Ng Select button.

Note: clearable is by default true

Related