简体   繁体   English

ng-multiselect-dropdown-angular7 (onDeSelect) 不起作用

[英]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当您选择一个选项时调用 OnSelectAll,您需要在打字稿文件中创建 onItemDeSelect 函数

and use this HTML :并使用此 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在 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然后在 xxx.component.ts 文件中

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并像这样在视图上使用 onDeSelect

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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