Is there a way to enable Select All functionality in Angular mat-select by using Boolean functions without the need for form tags or form builders?
Component.html
<div layout="column" class="mat-cloumn w-25">
<mat-form-field appearance="fill">
<mat-label>Location</mat-label>
<mat-select class="user-control" multiple>
<mat-option #allSelected (click)="toggleAllSelection()" [value]="0">All</mat-option>
<mat-option [value]="store.id" *ngFor="let store of stores">{{ store.name }}</mat-option>
</mat-select>
</mat-form-field>
</div>
component.ts
notSelectedAll = true;
stores = [
{id:1,name:'store - 1'},
{id:2,name:'store - 2'},
{id:3,name:'store - 3'},
{id:4,name:'Store - 4'}
];
toggleAllSelection(){
if(this.notSelectedAll = !this.notSelectedAll){
console.log(false)
}else{
console.log(true)
}
}
Looking for a solution to implement select all feature in angular mat-select