In React, I could easily do the following to nest two components whose actual type was not known until runtime, and whose class types were supplied as props:
render() {
const FirstComponent = this.props.comp1;
const SecondComponent = this.props.comp2;
return (
<FirstComponent>
<SecondComponent></SecondComponent>
</FirstComponent>
);
}
How would do I do the equivalent in Angular? The Angular documentation explains how to create a dynamic component as a view child of itself, but not how a component can set a dynamic component as the content child of another dynamic component.
Basically, I want to be able to have the following:
<my-component [comp1]="FirstComponentClass" [comp2]="SecondComponentClass"></my-component>
And at runtime, produce the equivalent component hierarchy:
<my-component>
<first-component>
<second-component></second-component>
</first-component>
</my-component>
How would I implement my-component?