【发布时间】:2016-05-24 16:15:49
【问题描述】:
我正在使用 Angular 制作应用程序,目前正在处理表单部分。在自定义 ngFormModel 的帮助下,我可以通过以下验证生成每个定义的表单:
<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.customForm = this.form.group({
'name': [this.user.first_name],
'email': [this.user.email]});
【问题讨论】: