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
  • 6,183
  • 6
  • 41
  • 52
sundeepg
  • 432
  • 2
  • 8
  • 18
  • 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. – sundeepg 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,363
  • 1
  • 13
  • 23