A basic input component is created on the fly
const compTag = 'my-input';
const template = `<${compTag}></${compTag}>`;
my-input
is an input which implements the ControlValueAccessor
and can be assigned with a formControlName
directive.
therefore, passing it a formControlName=${config.name}
:
const template = `<${compTag} formControlName="${config.name}"></${compTag}>`;
in my on-the-fly component, the following is passed so that the control will find his parent:
viewProviders: [{
provide: ControlContainer,
useExisting: FormGroupDirectiv
}],
Verbose:
const tmpCmp = Component({
template,
viewProviders: [{
provide: ControlContainer,
useExisting: FormGroupDirective
}],
})(class {});
which is later resolved in DOM as:
<ng-component>
<my-input formcontrolname="a" ng-reflect-name="a" class="ng-untouched ng-pristine ng-valid">
<input/>
</my-input>
</ng-component>
The problem is when I attempt to pass any Object config data to the child component in the template:
const template = `<${compTag} formControlName="${config.name}" config=${config}></${compTag}>`;
the config
does pass on to the component, but not parsed properly, and received as config: [Object object]
has anyone stumbled upon?