For all custom form controls, you must register a value accessor.
Here's an example of how to provide one:
providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MyInputField), multi: true, } ]
As described above, your control was expected to have a value accessor, but was missing one. However, there are many different reasons this can happen in practice. Here's a listing of some known problems leading to this error.
ngModel
on an element with no value, or an invalid element (e.g. <div [(ngModel)]="foo">
)?NgModule
? if so, make sure you are importing the NgModule
.ngModel
with a third-party custom form control? Check whether that control provides a value accessor. If not, use ngDefaultControl
on the control's element.Testbed.configureTestingModule
.webpack.config.js
may require extra configuration to ensure the forms package is shared.
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/errors/NG01203