import {Injectable, TemplateRef} from '@angular/core'; import {Observable, Subject} from 'rxjs'; import {WindowRef, WindowService} from '@progress/kendo-angular-dialog'; @Injectable({ providedIn: 'root', }) export class AppWindowPopUp { public _window: WindowRef; public _subject: Subject = new Subject(); public _boObject: any; private _width = 625; private _height = 325; private _top = 50; private _left = 250; constructor(private windowService: WindowService) { // if (this._window.result != undefined) { // this._window.result.subscribe((result) => { // if (result instanceof WindowCloseResult) { // this._subject.next("No Return value"); // } // }); // } } public show(scontent: string | TemplateRef | any, Title: string, boObject: any, Width?: number, Height?: number , Top?: number, Left?: number): Observable { let cwidth = this._width; let cheight = this._height; let ctop = this._top; let cleft = this._left; this._boObject = boObject; if (Width !== undefined) { cwidth = Width; } if (Height !== undefined) { cheight = Height; } if (Top !== undefined) { ctop = Top; } if (Left !== undefined) { cleft = Left; } this._window = this.windowService.open({ title: Title, content: scontent, width: cwidth, height: cheight, left: cleft, top: ctop, }); this._subject.unsubscribe(); this._subject = new Subject(); return this._subject.asObservable(); } public Close(returnValue?: any) { this._subject.next(returnValue); this._window.close(); } }