diff --git a/components/modal/modal.component.ts b/components/modal/modal.component.ts index eea0bd6bfb..07eca5d9aa 100644 --- a/components/modal/modal.component.ts +++ b/components/modal/modal.component.ts @@ -16,7 +16,6 @@ import { Output } from '@angular/core'; import {global} from '@angular/core/src/facade/lang'; -import {DOCUMENT} from '@angular/platform-browser'; import {ModalBackdropComponent, ModalBackdropOptions} from './modal-backdrop.component'; import {modalConfigDefaults, ClassName, ModalOptions, Selector} from './modal-options.class'; import {ComponentsHelper} from '../utils/components-helper.service'; @@ -67,7 +66,9 @@ export class ModalDirective implements AfterViewInit, OnDestroy { private element:ElementRef; private renderer:Renderer; - private document:any; + private get document():any { + return this.componentsHelper.getDocument(); + }; private componentsHelper:ComponentsHelper; /** Host element manipulations */ @@ -92,11 +93,9 @@ export class ModalDirective implements AfterViewInit, OnDestroy { public constructor(element:ElementRef, renderer:Renderer, - @Inject(DOCUMENT) document:any, @Inject(ComponentsHelper) componentsHelper:ComponentsHelper) { this.element = element; this.renderer = renderer; - this.document = document; this.componentsHelper = componentsHelper; } @@ -109,8 +108,6 @@ export class ModalDirective implements AfterViewInit, OnDestroy { this.isBodyOverflowing = void 0; this.originalBodyPadding = void 0; this.scrollbarWidth = void 0; - - this.document = void 0; } public ngAfterViewInit():any { diff --git a/components/utils/components-helper.service.ts b/components/utils/components-helper.service.ts index 95920c53e5..52e8c8b31c 100644 --- a/components/utils/components-helper.service.ts +++ b/components/utils/components-helper.service.ts @@ -3,6 +3,8 @@ import { Injectable, ReflectiveInjector, Provider, Injector } from '@angular/core'; +import {DOCUMENT} from '@angular/platform-browser'; + /** * Components helper class to easily work with * allows to: @@ -13,14 +15,18 @@ export class ComponentsHelper { private applicationRef:ApplicationRef; private componentResolver:ComponentResolver; - private injector: Injector; + private injector:Injector; - public constructor(applicationRef:ApplicationRef, componentResolver:ComponentResolver, injector: Injector) { + public constructor(applicationRef:ApplicationRef, componentResolver:ComponentResolver, injector:Injector) { this.applicationRef = applicationRef; this.componentResolver = componentResolver; this.injector = injector; } + public getDocument():any { + return this.injector.get(DOCUMENT); + } + /** * This is a name conventional class to get application root view component ref * to made this method working you need to add: