I have a couple references to the window object in my Angular JSS component:
@HostListener('window:resize', ['$event'])
onResize(event) {
if (window && typeof window !== 'undefined') {
this.width = window.innerWidth;
}
}
and
ngOnInit() {
if (window && typeof window !== 'undefined') {
this.width = window.innerWidth;
}
}
Even with the null/undefined check, either of these two blocks causes the Experience Editor to throw errors when a component is added to a page:
Uncaught Loaded unexpected element while trying to get rendering html from server. Expecting last tag to be closing script marker