使用formControlName和ngModel的角度6警告 [英] angular 6 warning for using formControlName and ngModel
问题描述
我最近将角度版本升级为6-rc.我收到以下警告
I recently upgraded the angular version to 6-rc. I got following warning
您似乎在与ng相同的表单字段上使用ngModel formControlName.支持使用ngModel输入属性和 带有反应形式指令的ngModelChange事件已被弃用 在Angular v6中将被删除,并将在Angular v7中被删除
It looks like you're using ngModel on the same form field as formControlName. Support for using the ngModel input property and ngModelChange event with reactive form directives has been deprecated in Angular v6 and will be removed in Angular v7
有关此的更多信息,请参见此处的API文档: https://angular.io/api/forms/FormControlName#use-with-ngmodel
For more information on this, see our API docs here: https://angular.io/api/forms/FormControlName#use-with-ngmodel
它到底在说什么?链接没有#use-with-ngmodel
What does it say exactly? the link does not have any fragment for #use-with-ngmodel
我想我需要删除ngModel
并将formGroup用作我的数据绑定对象.
I guess I need to remove ngModel
and use formGroup as my data binding object.
推荐答案
如果您现在正在寻找Angular 6文档,请使用 https://next.angular.io
If you're looking for Angular 6 documentation right now then use https://next.angular.io
https://next.angular.io/api/forms/FormControlName#use-with-ngmodel
因此,您有3个选择:
-
使用反应形式
use Reactive forms
使用模板驱动的表单
静音警告(不推荐)
imports: [
ReactiveFormsModule.withConfig({warnOnNgModelWithFormControl: 'never'});
]
这篇关于使用formControlName和ngModel的角度6警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!