问题描述
限时送ChatGPT账号..我最近将 angular 版本升级到了 6-rc.我收到以下警告
I recently upgraded the angular version to 6-rc. I got following warning
看起来你在同一个表单域上使用 ngModel表单控件名称.支持使用 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 个选择:
So you have 3 options:
使用响应式表单
use Reactive forms
使用模板驱动的表单
静音警告(不推荐)
imports: [
ReactiveFormsModule.withConfig({warnOnNgModelWithFormControl: 'never'});
]
这篇关于使用 formControlName 和 ngModel 的 angular 6 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论