Created
September 8, 2016 12:10
-
-
Save qdouble/2641d5013208b5102ce3375ff27a1d12 to your computer and use it in GitHub Desktop.
Window service
This file contains 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 { OpaqueToken } from '@angular/core' | |
var win = typeof window !== 'undefined' && window || <any>{}; | |
export { win as window }; | |
function CONST_EXPR(expr) { | |
return expr; | |
} | |
function _window(): any { | |
return window | |
} | |
export const WINDOW: OpaqueToken = CONST_EXPR(new OpaqueToken('WindowToken')); | |
export abstract class WindowRef { | |
get nativeWindow(): any { | |
throw new Error('unimplemented'); | |
} | |
} | |
export class WindowRef_ extends WindowRef { | |
constructor() { | |
super(); | |
} | |
get nativeWindow(): any { | |
return _window(); | |
} | |
} | |
export const WINDOW_PROVIDERS = [ | |
{ provide: WindowRef, useClass: WindowRef_ }, | |
{ provide: WINDOW, useFactory: _window, deps: []} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment