import { Component, ElementRef, ComponentFactoryResolver, ViewContainerRef } from '@angular/core'; import { RdComponent } from '../../base/rdComponent'; @Component({ selector: 'rd-sweet-instance', template: "" }) export class SweetAlertInstance extends RdComponent { private contentReferance; constructor(private view: ViewContainerRef, private loader: ComponentFactoryResolver) { super(); } open(contentComponent, callback) { if (this.contentReferance) this.contentReferance.destroy(); let factory = this.loader.resolveComponentFactory(contentComponent); let ref = this.view.createComponent(factory); this.contentReferance = ref; ref.instance["element"] = ref.location; callback(ref.instance); ref.changeDetectorRef.detectChanges(); } close() { this.contentReferance.destroy(); this.contentReferance.instance.dxSweetAlertInstance.hide(); } }