Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import {Injectable, Provider} from 'angular2/angular2'
import {window} from 'angular2/src/facade/browser';
import {unimplemented} from 'angular2/src/facade/exceptions';
function _window(): Window {
return window
export abstract class WINDOW {
get nativeWindow(): Window {
return unimplemented();
class WindowRef_ extends WINDOW {
constructor() {
get nativeWindow(): Window {
return _window();
export const WINDOW_PROVIDERS = [
new Provider(WINDOW, {useClass: WindowRef_}),

This comment has been minimized.

Copy link
Owner Author

@lokanx lokanx commented Dec 10, 2015

And to use it:

import {WINDOW} from './windowService';

export class PersonStorageService {
    win: Window;

    constructor(win: WINDOW) { = win.nativeWindow;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment