How to change radio button selection in a radio group that uses a for loop? I want to use the changeRadio method to select (and trigger the change) the radio button based on a received 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 tried with _inputElement but it seems to select allways the first element and do not tigger the change event.