Reputation: 2444
I have a formcontrol as radio buttons as follow
<div class="form-group">
<label for="">Activity Time</label><br/>
<input type="radio" value="0" (change)="handleActivityTime(false)" formControlName="activityTime"> By Select
<input type="radio" value="1" (change)="handleActivityTime(true)" [checked]="true" formControlName="activityTime"> By Input
</div>
and in my component.ts I create the form control. Here I'm assigning the By Input as the default one and make it as checked. But it is not able to check.
Upvotes: 1
Views: 2953
Reputation: 2444
The issue is value should be indicate on [value]
<div class="form-group">
<label for="">Activity Time</label><br/>
<input type="radio" value="0" (change)="handleActivityTime(false)" formControlName="activityTime"> By Select
<input type="radio" value="1" (change)="handleActivityTime(true)" [checked]="true" formControlName="activityTime"> By Input
</div>
is working for me. also no need to create formconrol object on the form
Upvotes: 4