【发布时间】:2022-01-19 23:28:10
【问题描述】:
在调用 ts 文件的 html 文件中使用以下代码。每次用户单击左移或右移按钮时都需要调用切换功能的帮助,因此选择可能是错误的。
https://stackblitz.com/edit/angular-listbox?file=src%2Fapp%2Fapp.component.html
【问题讨论】:
标签: angular typescript frontend
在调用 ts 文件的 html 文件中使用以下代码。每次用户单击左移或右移按钮时都需要调用切换功能的帮助,因此选择可能是错误的。
https://stackblitz.com/edit/angular-listbox?file=src%2Fapp%2Fapp.component.html
【问题讨论】:
标签: angular typescript frontend
一旦你移动任何东西或所有东西,你就可以有一个通用函数为你取消选择。
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));
}
【讨论】: