In my html template I'm having multiple elements generated by *ngFor.
I am successfully able to subscribe to their value changes in the ngAfterViewInit lifecycle hook.
However, I am not able to set the .checked property via code.
Does somebody spot my error? Any help is really appreciated!
export class GroupsExpPanelComponent implements AfterViewInit {
@ViewChildren('confirm') confirm: QueryList < MatButtonToggle > ;
confirmToggles: MatButtonToggle[] = [];
ngAfterViewInit() {
this.confirm.changes
.subscribe(
res => {
this.confirmToggles = res.toArray();
}
);
}
<mat-button-toggle #confirm>Title</mat-button-toggle>
I would have expected to be able to set my properties like so
this.confirmToggles[index].checked = true;