ngModel cannot be used to register form controls with a parent formGroup directive

前端 未结 10 2064
猫巷女王i
猫巷女王i 2020-12-04 17:21

After upgrading to RC5 we began getting this error:

ngModel cannot be used to register form controls with a parent formGroup 
 directive.
Try using formGroup\         


        
10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 17:59

    If you want to use [formGroup] with formControlName, you must replace name attribute with formControlNameformControlName.

    Example:

    This does not work because it uses the [formGroup] and name attribute.

    You should replace the name attribute by formControlName and it will work fine like this following:

提交回复
热议问题