themyth92 / ngx-lightbox

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

Angular Universal : ReferenceError: Document is not defined #41

Closed iwoogy closed 4 years ago

iwoogy commented 4 years ago

Hello

Thanks for your component, it has been really useful.

I'm about to deploy and I found an issue with Angular Universal.

I got the error ReferenceError: Document is not defined.

2019-11-14_19-29-39

2019-11-14_19-28-47

I followed the instruction on Angular Universal by adding global['window'] = window; in server.ts

2019-11-14_19-29-07

2019-11-14_19-27-30

Thanks for your help

Bobby

themyth92 commented 4 years ago

Do window lib installed and import already ? Also are u using the latest ngx-lightbox. Latest version should be 2.1.1

iwoogy commented 4 years ago

I upgraded ngx-lightbox to version 2.1.1 from 2.0.0 and I installed window too.

2019-11-15_17-39-33

I required window in server.ts

2019-11-15_17-25-03

Then I have this error :

2019-11-15_17-31-24

Do you have an idea how to fix it ?

themyth92 commented 4 years ago

Hey I dont know whether this error relates to lightbox. Maybe this issue is related ?

iwoogy commented 4 years ago

Could be.

I think it's better to avoid dependencies on window for Angular Universal.

Let's close this ticket.

themyth92 commented 4 years ago

Yeah I agree that using extra dependancy is not really needed. However, if u have any solutions that would not require using window dependancy, PR is always welcomed and I would be more than happy to merge it.

MehmetSert commented 3 years ago

I encountered the "window" problem. I solved it using "domino". I share my files, maybe for someone's benefit.

package.json Screenshot at Dec 02 02-08-15

server.ts Screenshot at Dec 02 02-07-55