This happens because when you change valueAccessor Angular doesn’t register onChange and onTouched events on that new component again.

What you can try as workaround is to register those events manually:

const ngControl = this.injector.get(NgControl);
const valueAccessor = ngControl.valueAccessor as any;
if (valueAccessor && valueAccessor.onChange) {
ngControl.valueAccessor = this.componentRef.instance;

Forked Stackblitz

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top