-
-
Save lokanx/cc022ee0b8999cd3b7f5 to your computer and use it in GitHub Desktop.
window-service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | |
super(); | |
} | |
get nativeWindow(): Window { | |
return _window(); | |
} | |
} | |
export const WINDOW_PROVIDERS = [ | |
new Provider(WINDOW, {useClass: WindowRef_}), | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And to use it: