Inside my component class, I am attempting to set a form radio button value to 1:
import { FormGroup, FormControl } from '@angular/forms';
export class RadioComponent implements OnInit{
pageForm: FormGroup;
ngOnInit() {
this.pageForm = new FormGroup({
'gender': new FormControl(1)
});
}
}
However, upon loading the page, the radio button does not default to "Male" and both options appear blank:
<div class="form-group">
<label for="gender">Gender</label>
<div class="radio">
<label>
<input type="radio" name="gender" formControlName="gender" value=1>Male
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="gender" formControlName="gender" value=0>Female
</label>
</div>
</div>
How can I correctly load the radio button value from my component class?