"onDropDownClose" 即使我点击 ng-multiselect-dropdown 中下拉列表以外的任何其他地方,事件也会一直被触发

"onDropDownClose" event is getting triggered all time even if I click any where else other than the drop down in ng-multiselect-dropdown

我正在使用 ng-multiselect-dropdown,我必须根据所选列表加载数据。 因此,我正在使用“onDropDownClose”事件来获取所有选定的值并根据选定的多个值加载其他数据。

   <ng-multiselect-dropdown
   [placeholder]="'Select Project'"
   [settings]="dropdownSettings"
   [data]="projects"
   [required]='requiredField' 
   [(ngModel)]="selectedItems"
   name="projectName"
   [ngClass]='setClass()'
  #projectName="ngModel"
  (onSelect)="onItemSelect($event)"
  (onSelectAll)="onSelectAll($event)" 
  (onDropDownClose)="saveFunction($event)">

但是关闭事件一直在触发,即使我总是在下拉菜单外点击。 有什么替代方法吗?请帮忙

这应该在他们结束时解决,但在那之前你可以使用这个技巧: 除了 (onDropDownClose),在 ng-multiselect-dropdown

上监听点击事件
 // this act as a differentiator between other calls(bug) and an intended call
 (click)="dropDownSelect = true".

在您的组件中,声明您的变量并像这样使用它:

dropDownSelect = false;

saveFunction($event) {
 if (this.dropDownSelect) {
        // close the opening to subsequent actions 
        this.dropDownSelect = false;
        // Perform action;
 };
}