ngx-sortablejs icon indicating copy to clipboard operation
ngx-sortablejs copied to clipboard

Angular Universal: SSR - window is not defined

Open nncl opened this issue 5 years ago • 2 comments

Hello,

I'm using ngx-sortablejs in my application, and works as expected, the only problem is that this same application uses Angular Universal to server side rendering, and the following error is returned from the server:

ReferenceError: window is not defined
    at new Sortable (/var/www/app/dist/server/main.js:121650:73)
    at Function.Sortable.create (/var/www/app/dist/server/main.js:123098:12)
    at Timeout.<anonymous> (/var/www/app/dist/server/main.js:135544:87)
    at ZoneDelegate.invokeTask (/var/www/app/dist/server.js:578:31)
    at Zone.runTask (/var/www/app/dist/server.js:350:47)
    at ZoneTask.invokeTask (/var/www/app/dist/server.js:653:34)
    at Timeout.ZoneTask.invoke (/var/www/app/dist/server.js:642:48)
    at Timeout.timer [as _onTimeout] (/var/www/app/dist/server.js:2387:29)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

Is there anything to do in order to avoid its load on the server side? Or is it something that the original library should - maybe - do?

By now I'm handling this problem with isPlatformBrowser and not rendering it through *ngIf, but it doesn't look nice.

Thanks for your great work.

nncl avatar Feb 13 '20 23:02 nncl

Have the same issue. any update about this bug? it used to works fine

lares83 avatar Mar 27 '20 08:03 lares83

@nncl https://github.com/angular/universal/issues/1523#issuecomment-600320144 please check this, I think it's helpful.

carbonhe avatar Oct 22 '20 09:10 carbonhe