Я хотел бы добавить динамический компонент из службы.Мой компонент BubbleComponent.
import { BubbleComponent } from '@app/component/bubble';
import {SiplecService} from '@app/service/siplec.service';
@NgModule({
imports: [
FormsModule,
CommonModule,
NgbModule,
RouterModule.forChild(HomeRoutes),
],
declarations: [HomeComponent, BasketComponent, BubbleComponent],
entryComponents: [ BubbleComponent ],
providers: [ SiplecService ]
})
export class HomeModule {}
В моем сервисе:
setRootViewContainerRef(viewContainerRef: any) {
this.rootViewContainer = viewContainerRef;
}
addDynamicComponent() {
const factory = this.factoryResolver
.resolveComponentFactory(BubbleComponent);
const component = factory
.create(this.rootViewContainer.parentInjector);
this.rootViewContainer.insert(component.hostView);
}
Я получаю следующую ошибку:
Ошибка: не найдена фабрика компонентов дляBubbleComponent.Вы добавили его в @ NgModule.entryComponents?at noComponentFactoryError (core.js: 7409)