Angular 2 形式;ngFormControl 用于收音机和选择 [英] Angular 2 forms; ngFormControl for radio and select

查看:32
本文介绍了Angular 2 形式;ngFormControl 用于收音机和选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Angular 中制作一个应用程序,目前正在处理表单部分.在自定义 ngFormModel 的帮助下,我可以使用以下简单的验证生成每个定义的表单:

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>

这非常有效,我的预定义表单的默认值会自动显示,并在我提交值时更新我的​​表单.我无法使用 ngFormControl 获取输入类型单选并选择启动和运行.这可能在 Angular 2 中不受支持吗?这难道不是表单的基本部分吗?

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?

可能与显示表单的生成方式有关:

maybe relevant to show how the form is generated:

this.customForm = this.form.group({
    'name': [this.user.first_name],
    'email': [this.user.email]});

推荐答案

收音机输入尚未得到很好的支持,并且存在各种已知问题.另请参阅 https://github.com/angular/angular/issues/8107https://github.com/angular/angular/search?q=radio&state=open&type=Issues&utf8=%E2%9C%93

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

这篇关于Angular 2 形式;ngFormControl 用于收音机和选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆