Created
May 15, 2017 12:37
-
-
Save evertonrobertoauler/aed3f2f50694c524d880ad1a5c5838f7 to your computer and use it in GitHub Desktop.
Access window
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 { PLATFORM_ID } from '@angular/core'; | |
import { isPlatformBrowser } from '@angular/common'; | |
@Component({...}) | |
export class DemoComponent implements OnInit { | |
constructor(@Inject(PLATFORM_ID) private platformId: Object) { } | |
ngOnInit() { | |
if (isPlatformBrowser(this.platformId)){ | |
// here you can access window | |
console.log(window); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment