当我点击右键或左键时,如何调用切换函数



在调用ts文件的html文件中使用以下代码。每次用户单击向左或向右移动按钮时都需要帮助调用切换函数,因此选择可能是错误的。

https://stackblitz.com/edit/angular-listbox?file=src%2Fapp%2Fapp.component.html

您可以有一个通用函数,在移动任何东西或所有东西后为您进行取消选择。

public moveSelected(direction) {
// Your existing code here
this.unselectAll(); // Add this common function
}
public moveAll(direction) {
// Your existing code here
this.unselectAll(); // Add this common function
}
public unselectAll() { // Use this function as a helper to unselect everything
this.list1.map((i) => (i.selected = false));
this.list2.map((i) => (i.selected = false));
}

最新更新