I'm using reactive form in angular 8, and have a gender toggle radio button. The toggle radio button don't return the value of selected.
html code
<form id="sb-signup-form" method="post" novalidate="" [formGroup]="registerForm" (ngSubmit)="register($event)">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary active">
<input id="male" type="radio" class="custom-control-input" value="male" name="gender" formControlName="gender"> Male
</label>
<label class="btn btn-primary">
<input id="female" type="radio" class="custom-control-input" value="female" name="gender" formControlName="gender"> Female
</label>
</div>
</form>
.ts code
registerForm: FormGroup;
ngOnInit() {
this.registerForm = this.formBuilder.group({
gender: ['male']
});
}
register(e) {
console.log(this.registerForm.value);
}
always the value of gender is 'male', which is the default value.