本文介绍了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/8107 https://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进行广播,然后选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 07:31