Issue
I tried now a few ways to set a mat radio button checked by default but none of these were working. Currently, my solution looks like that, which is also not working:
<mat-radio-group name="personTypOperator" [(ngModel)]="personTypOperator" (change)="sendToFilter()" >
<mat-radio-button checked value="and" > Und </mat-radio-button>
<mat-radio-button value="or" > Oder </mat-radio-button>
<mat-radio-button value="not"> Nicht </mat-radio-button>
</mat-radio-group>
I tried it this way through the "checked" element. I also tried [checked] before and it was also a failure. What is the correct way to do it?
Solution
To select the 1st radio button option by default, you can initialize the personTypOperator
property value in your Component ts
file as:
personTypOperator = 'and';
// in case if assignment done within any function
this.personTypOperator = 'and';
Answered By - Siddhant
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.