When you add angular universal in your app window, document, navigator, and other browser types - do not exist on the server - so using them, or any library that uses them (jQuery for example) will not work.
If you need to use them, consider limiting them to only your client and wrapping them situationally. You can use the Object injected using the PLATFORM_ID token to check whether the current platform is browser or server.
in My Project i have following code inside component ts file and it is working
import { WINDOW } from '@ng-toolkit/universal';
import { Component, Inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app';
constructor(@Inject(WINDOW) public window: Window,
@Inject(PLATFORM_ID) private platformId: Object) {
}
onActivate(event) {
if (isPlatformBrowser(this.platformId)) {
this.window.scroll(0, 0); // window object used which is Instance of Window
}
}
}