1

I am making an app in Angular and am currently working on a forms section. With the help of a custom ngFormModel I have can generate per defined forms with validation simply with the following:

<form [ngFormModel]="customForm" (ngSubmit)="updateUser()">
<input [ngFormControl]="customForm.controls['name']" type="text">
<input [ngFormControl]="customForm.controls['email']" type="text>
            <button *ngIf="customForm.dirty" type="submit">Save</button>
</form>

This works quite awesome, default values for my pre defined form are automatically shown and my form is updated when I submit the values. I have not been able to get input types radio and select up and running with ngFormControl. Is it possible that this isn't supported out of the box in Angular 2? Isn't this a quite fundamental part of forms?

Edit: maybe relevant to show how the form is generated:

this.customForm = this.form.group({
    'name': [this.user.first_name],
    'email': [this.user.email]});
hY8vVpf3tyR57Xib
  • 3,574
  • 8
  • 41
  • 86

1 Answers1

0

The radio input is not yet well supported and has various known issues. See also https://github.com/angular/angular/issues/8107 or https://github.com/angular/angular/search?q=radio&state=open&type=Issues&utf8=%E2%9C%93

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • How about the select type? I couldn't find a lot about that either, but that could possible be used to build a workaround. – hY8vVpf3tyR57Xib May 24 '16 at 08:19
  • Select should work. What Angular2 version are you using? I don't see a select being used in your question. What have you tried? What doesn't work. – Günter Zöchbauer May 24 '16 at 08:21
  • I tried to make an example in plunker but found out the the select type does work as expected, the issue therefor only is with the radio type. Thanks! – hY8vVpf3tyR57Xib May 24 '16 at 08:41