themyth92 / ngx-lightbox

Lightbox2 use with angular >= 5
MIT License
115 stars 70 forks source link

Fix "Document is not defined" issue with Angular Universal #37

Closed cozzbie closed 5 years ago

cozzbie commented 5 years ago

This PR references #25 and corrects it by referencing the document object directly from the window as opposed to using Angulars injection token which basically resolves to the same thing. In addition, for this to work with Angular Universal, you need to have a global window object defined in your server.js (the one in your Angular project derived from initiating an ssr project using Angular Universal) using any window npm lib like window or domino.

Add the below to your server.js

global['window'] = window;
themyth92 commented 5 years ago

Thanks @cozzbie a lot for your PR, will publish a new version soon