错误原因:在最外层的form中使用了 formGroup 指令,但在下面的某个input 元素中,使用了ngModel 指令,但没有加入formControl 指令或 formControlName 属性。
解决方法一
在input元素中添加 formControl 指令或 formControlName 属性
在input标签中添加即可:[ngModelOptions]="{standalone: true}" 或 formControlName="xxx";
解决方法二
不添加formControl 指令或 formControlName 属性, 而添加 ngModelOptions 指令
注意 ngModelOptions 必须和 ngModel 一起用!
查看更多关于angular 在formGroup中失效报错 ngModel cannot be used to的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did222727