我正在使用 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;
};
}
关于html - "onDropDownClose"事件一直被触发,即使我点击 ng-multiselect-dropdown 中下拉菜单以外的任何其他地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64729826/