简体   繁体   中英

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

With this following piece of code in html file which calls the ts file. Need help with calling the toggle function every time a user click on the left or right move button, so the selection can be false.

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

You can have a common function that does the unselection for you, once you move anything or everything.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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