I'm trying to create modal service with ability to show arbitrary modal. Currently, to create dynamic component, I'm storing placeholder for it in view:
<div #container></div>
...
@ViewChild("dialogContainer", {read: ViewContainerRef})
dialogContainer:ViewContainerRef;
And than creating component:
let factory = this.componentResolver.resolveComponentFactory(Dialog);
this.componentReference = this.dialogContainer.createComponent(factory);
Is there way to move all this logic out of component to service, with ability to create/remove view container in body, or any other DOM element?