0

I want to check a radio button on load of the page, which is also two-way binded. It is only happening when the ngModel is removed.

<input [(ngModel)] = "field.value" name="{{field.label}}" type="radio"
             [checked]="option.isDefaultOption=='true'?'true':null"/>
Kyle Krzeski
  • 5,600
  • 5
  • 36
  • 48
sunnyiitkgp
  • 372
  • 1
  • 7
  • 17
  • You might want to check this question here: https://stackoverflow.com/questions/40214655/angular-2-checkbox-two-way-data-binding – Mircea Pop Jul 06 '17 at 13:20
  • Yes. I saw that question too, before posting. But the solution asks me to make it one-way binding. Am checking if I can achieve that with 2-way binding. – sunnyiitkgp Jul 07 '17 at 06:18

1 Answers1

1

Try this in component

ngOnInit() {

   field.value = true;

}

and in the template

 <input [(ngModel)] = "field.value" name="{{field.label}}" type="radio"
         [value]="true" />
alehn96
  • 1,313
  • 1
  • 10
  • 22