单击右键或左键时如何调用切换功能?
How to call the toggle function when I click on the right or left button?
在 html 文件中使用以下代码调用 ts 文件。每次用户单击向左或向右移动按钮时都需要帮助调用切换函数,因此选择可能是错误的。
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));
}
在 html 文件中使用以下代码调用 ts 文件。每次用户单击向左或向右移动按钮时都需要帮助调用切换函数,因此选择可能是错误的。
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));
}