简体   繁体   English

Angular 2 表单控件更新

[英]Angular 2 Form Control Update

How do I apply [ngModel] to the FormControl.如何将 [ngModel] 应用到 FormControl。 Lets say I have a form with some required fields, based on the changes in the selectbox I want to update the form Control?假设我有一个包含一些必填字段的表单,基于我想更新表单控件的选择框中的更改?

It's best not to mix the two types of form reactive vs template meaning: FormControl with ngModel最好不要混合两种形式的响应式和模板含义: FormControlngModel

if you're using reactive, you can use this to update a form controls value this.myForm.get('SomeFormControl').patchValue('new value);如果您使用的是反应式,您可以使用它来更新表单控件值this.myForm.get('SomeFormControl').patchValue('new value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM