简体   繁体   中英

ng-multiselect-dropdown-angular7 (onDeSelect) not working

我正在尝试获取已取消选择的项目的 ID,但 (onDeSelect) 在 ng-multiselect-dropdown-angular7 中不起作用:显示图像这是我尝试使用的方法

the OnSelectAll is called when you select an option, you need to create onItemDeSelect function in your typescript file

and use this HTML :

<ng-multiselect-dropdown-angular7 [placeholder]="'custom placeholder' [data]="dropdownList" [(ngModel)]="selectedItems" [settings]="dropdownSettings" (onSelect)="onItemSelect($event)" (onSelectAll)="onSelectAll($event)" (onDeSelect)="onItemDeSelect($event)"> </ng-multiselect-dropdown-angular7>

LIVE VERSION

Here is my code

In HTML

    <ng-multiselect-dropdown class=""
          placeholder="Select value" 
          [data]="dropdownData"
          [settings]="dropdownSettings"
          (onSelect)="onItemSelect($event)"
          (onSelectAll)="onSelectAll($event)"
          (onDeSelect)="onItemDeSelect($event)"
          (onDeSelectAll)="onDeSelectAll($event)">
      </ng-multiselect-dropdown> 

then in xxx.component.ts file

onDeSelectAll(items: any){
    //here you have access to all items
}

Define the Event in the Component like this

  onItemDeSelect(item: any) {
    console.log('onItemDeSelect', item);
  }

and use onDeSelect on the View like this

<ng-multiselect-dropdown-angular7 ... (onDeSelect)="onItemDeSelect($event)"></ng-multiselect-dropdown-angular7>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM