【问题标题】:How to call the toggle function when I click on the right or left button?单击右键或左键时如何调用切换功能?
【发布时间】:2022-01-19 23:28:10
【问题描述】:

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

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

【问题讨论】:

    标签: angular typescript frontend


    【解决方案1】:

    一旦你移动任何东西或所有东西,你就可以有一个通用函数为你取消选择。

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

    【讨论】:

      猜你喜欢
      • 2022-12-17
      • 2015-03-03
      • 2019-05-03
      • 2018-11-18
      • 2015-07-14
      • 1970-01-01
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多