I'm creating dynamic component in Angular v6 using compileModuleAndAllComponentsAsync of angular compiler with same below code.
viewChangeMethod(view: string) {
let template = `<span>${view} </span>`;
const tmpCmp = Component({ template: template })(class { });
this._compiler.clearCacheFor(this.tmpModule)
this.tmpModule = NgModule({ declarations: [tmpCmp,FRAComponent],import:[ComonModule] })(class {
});
this._compiler.compileModuleAndAllComponentsAsync(this.tmpModule)
.then((factories) => {
const f = factories.componentFactories[0];
const cmpRef = f.create(this._injector, [], null, this._m);
this._container.detach()
console.log(cmpRef.hostView)
this._container.insert(cmpRef.hostView);
})
this._compiler.clearCacheFor(this.tmpModule)
}
Every thing is working fine but when importing any shared module or custom module below error.