Commit 77591ca3 authored by avovchuk's avatar avovchuk

lazy create dialogs holder

parent fcf9c493
......@@ -19,9 +19,7 @@ export class DialogService {
* @param {ApplicationRef} applicationRef
* @param {Injector} injector
*/
constructor(private resolver: ComponentFactoryResolver, private applicationRef: ApplicationRef, private injector: Injector) {
this.dialogHolderComponent = this.createDialogHolder();
}
constructor(private resolver: ComponentFactoryResolver, private applicationRef: ApplicationRef, private injector: Injector) {}
/**
* Adds dialog
......@@ -31,6 +29,9 @@ export class DialogService {
* @return {Observable<any>}
*/
addDialog(component:Type<DialogComponent>, data?:any, index?:number): Observable<any> {
if(!this.dialogHolderComponent) {
this.dialogHolderComponent = this.createDialogHolder();
}
return this.dialogHolderComponent.addDialog(component, data, index);
}
......@@ -39,6 +40,9 @@ export class DialogService {
* @param {DialogComponent} component
*/
removeDialog(component:DialogComponent): void {
if(!this.dialogHolderComponent) {
return;
}
this.dialogHolderComponent.removeDialog(component);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment