繁体   English   中英

单击右或左按钮时如何调用切换 function?

[英]How to call the toggle function when I click on the right or left button?

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

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

一旦您移动任何东西或所有东西,您就可以拥有一个通用的 function 来为您取消选择。

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));
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM