79282674

Date: 2024-12-15 16:07:32
Score: 0.5
Natty:
Report link

In whatever component you are using window, inject PLATFORM_ID as well:

constructor(@Inject(PLATFORM_ID) private platformId: Object) {}

ngOnInit() {
  if (isPlatformBrowser(this.platformId)) {
    // This code will only run in the browser
    console.log(window);
  }
}

Now you're good to go.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: PPFromInfy