Skip to content

Commit

Permalink
fix(modal): injected DOCUMENT token is undefined
Browse files Browse the repository at this point in the history
fixes #575
  • Loading branch information
valorkin committed Jul 14, 2016
1 parent b4267aa commit 48a9aa7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 3 additions & 6 deletions components/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}

Expand All @@ -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 {
Expand Down
10 changes: 8 additions & 2 deletions components/utils/components-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 48a9aa7

Please sign in to comment.