How to add an ngModel and formControlName together in an angular custom component?

Viewed 179
2 Answers

So what you're looking for is the ControlValueAccessor interface: https://angular.io/api/forms/ControlValueAccessor

If you implement this interface on your component, the methods of the interface will allow the component to work with both template driven and reactive forms (ngModel and formControl/formControlName). For clarity, you don't need ngModel or formControlName as Inputs on your component, this interface will cause this to be allowed.

Thanks to @Plabbee .It works like a charm.Just implement this interface ControlValueAccessor

Related