angularangular-reactive-formsform-controlcontrolvalueaccessor

Custom component FormControl pass value to parent component


I have a custom form control component implementing controlValueAccessor and working fine when used directly in a formGroup.

But now I'm trying to use my custom form control component in a "wrapper" component and using this wrapper component instead in my form.

I'm really struggling to do so, do I need to implement again a controlValueAccessor on my wrapper component ? I just want my wrapper component to pass the value to the form.

Here's a stackblitz: https://stackblitz.com/edit/angular-8kllvf


Solution

  • Implementing controlValueAccessor would be an option. Passing FormControl as an input an alternative: https://stackblitz.com/edit/angular-8kllvf-lw1pwn?file=src/app/profile-editor/profile-editor.component.html