簡體   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