Code
parent component
html:
< ng-container * ngComponentOutlet= "switchComponent" > < / ng-container >
ts:
public switchComponent = null;
constructor () {
this.switchComponent = PatientRecordComponent;
}
subcomponents
< div * ngif= "false" > ssss < / div >
try to solve
parent component
html:
< ng-container * ngComponentOutlet= "switchComponent; ngModuleFactory: myModule;" > < / ng-container >
ts:
import {NgModuleFactory, Compiler} from"@ angular/core";
import {PatientRecord} from". / common/patient/record/record.module";
public switchComponent = null;
myModule: NgModuleFactory
constructor (compiler: Compiler) {
this.myModule = compiler.compileModuleSync(PatientRecord);
this.switchComponent = PatientRecordComponent;
}