我最近将 Angular 版本升级到了 6-rc。我收到以下警告
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
For more information on this, see our API docs here: https://angular.io/api/forms/FormControlName#use-with-ngmodel
具体是什么意思?该链接没有任何 #use-with-ngmodel
我想我需要删除 ngModel
并使用 formGroup 作为我的数据绑定(bind)对象。
最佳答案
现在您可以在此处找到文档:
https://angular.io/api/forms/FormControlName#use-with-ngmodel-is-deprecated
所以你有 3 个选择:
使用响应式表单
使用模板驱动的表单
静音警告(不推荐)
<!-- language: lang-ts -->
imports: [
ReactiveFormsModule.withConfig({warnOnNgModelWithFormControl: 'never'});
]
关于使用 formControlName 和 ngModel 的 Angular 6 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49918503/