Jeanluca Scaljeri
Jeanluca Scaljeri

Reputation: 29097

Default check radio with reactive forms

I have a radio group and I would like to initially have one checked

this.form = new FormGroup({
  'test': new FormControl('AAA')
});

And the corresponding HTML

<form [formGroup]="form">
    <input name="test" type="radio" value="AAA" formControllName="test"> AAA   

   <input name="test" type="radio" value="AAA" formControllName="test"> BBB
</form>

DEMO

I've initialized the fromControl with a value of AAA, but it doesn't check the first radio button. Any suggestions what is I do wrong here?

Upvotes: 0

Views: 209

Answers (1)

Chellappan வ
Chellappan வ

Reputation: 27293

You have sytax error. It's should be formControlName

<form [formGroup]="form">
   <input name="test" type="radio" value="AAA" formControlName="test"> AAA   
   <br> 
   <input name="test" type="radio" value="AAA" formControlName="test"> BBB
</form>

Upvotes: 4

Related Questions