'How can I bind my selectAll button in Angular to an $event change?

May I know how to trigger the $event on the click of my selectAll button in Angular? My code are as follows:

<div class = "col-md-auto" id = "container">
<label><b>Apples</b></label>  
    <ng-select [items]="apple_list" [multiple]="true" [clearable]="false" (ngModelChange)="appleChange($event)" [(ngModel)]="selectedApple" required appendTo="body">
        <ng-template ng-header-tmp>
            <button (click)="selectAll('Apple')" class="btn btn-sm btn-primary">Select all</button>
            <button (click)="unselectAll('Apple')" class="btn btn-sm btn-secondary">Unselect all</button>
        </ng-template>
        <ng-template ng-option-tmp let-item="item" let-item$="item$" let-index="index">
            <input type="checkbox" [ngModel]="item$.selected"> {{item}}
        </ng-template>
    </ng-select>

And my selectAll function are as follows:

selectAll(dropdown) {
        if (dropdown === 'Apple') {
          this.selectedApple = this.apple_list
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source