Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Is there something preventing you to use the following syntax in your service window.onresize = ... ? Commented Jul 4, 2018 at 17:23
  • @Ploppy I'm not sure that will work as Angular SSR won't know what "window" is? Commented Jul 4, 2018 at 17:26
  • I did not read carefully and missed the SSR part, but then, I think you are doing alright, you even debounce the observable. I don't see anything bad but wait for some more people to confirm. Commented Jul 4, 2018 at 17:35
  • 1
    Why don't you check the platform is to only add the event handler if you are client side? Commented Jul 4, 2018 at 18:17
  • @David I tried wrapping the this.eventManager.addGlobalEventListener in an isPlatform check which then loads server-side fine but when it transfers state to client-side it errors. I assume because at that point the WindowService constructor has already initialised and angular doesn't re-initialise the globalEventListener. Commented Jul 5, 2018 at 7:28