UNPKG

ngx-modialog

Version:
74 lines (73 loc) 2.41 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import { ApplicationRef, Injector, Injectable } from '@angular/core'; import { createComponent } from '../framework/createComponent'; import { DialogRef } from '../models/dialog-ref'; import { ModalOverlay } from '../overlay/index'; export class DOMOverlayRenderer { /** * @param {?} appRef * @param {?} injector */ constructor(appRef, injector) { this.appRef = appRef; this.injector = injector; this.isDoc = !(typeof document === 'undefined' || !document); } /** * @param {?} dialog * @param {?} vcRef * @param {?=} injector * @return {?} */ render(dialog, vcRef, injector) { if (!injector) { injector = this.injector; } const /** @type {?} */ cmpRef = createComponent({ component: ModalOverlay, vcRef, injector: Injector.create([ { provide: DialogRef, useValue: dialog } ], injector) }); if (!vcRef) { this.appRef.attachView(cmpRef.hostView); // TODO: doesn't look like this is needed, explore. leaving now to be on the safe side. dialog.onDestroy.subscribe(() => this.appRef.detachView(cmpRef.hostView)); } if (vcRef && dialog.inElement) { vcRef.element.nativeElement.appendChild(cmpRef.location.nativeElement); } else if (this.isDoc) { document.body.appendChild(cmpRef.location.nativeElement); } return cmpRef; } } DOMOverlayRenderer.decorators = [ { type: Injectable }, ]; /** @nocollapse */ DOMOverlayRenderer.ctorParameters = () => [ { type: ApplicationRef, }, { type: Injector, }, ]; function DOMOverlayRenderer_tsickle_Closure_declarations() { /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */ DOMOverlayRenderer.decorators; /** * @nocollapse * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>} */ DOMOverlayRenderer.ctorParameters; /** @type {?} */ DOMOverlayRenderer.prototype.isDoc; /** @type {?} */ DOMOverlayRenderer.prototype.appRef; /** @type {?} */ DOMOverlayRenderer.prototype.injector; } //# sourceMappingURL=dom-modal-renderer.js.map