Is there a way to change the selected radio button in a radio group that is generated using a for loop? I am attempting to utilize the changeRadio function to select and trigger the change of the radio button based on a specific value.
<mat-radio-group (change)="onHobbyChange()">
<mat-radio-button *ngFor="let hobby of hobbies" [value]="hobby.favorite">
</mat-radio-button>
</mat-radio-group>
changeRadio(value){
const event = new MouseEvent('click', {bubbles: true});
this.matRadioButton._inputElement.nativeElement.dispatchEvent(event);
}
I attempted to use _inputElement but it appears to always select the first element and does not trigger the change event as desired.