Closed guillermodelagala closed 1 year ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
anyone?
Did anyone manage to fix this?
Description
I have a SPA in which if I refresh it, the lightgallery in Angular SSR gives an error:
TypeError: Cannot read properties of undefined (reading 'destroy') at LightgalleryComponent.ngOnDestroy (C:\GIT\xxx\frontend\xxx\main.js:149677:13) at executeOnDestroys (C:\GIT\xxx\frontend\xxx\main.js:375290:20) at cleanUpView (C:\GIT\xxx\frontend\xxx\main.js:375204:5) at destroyViewTree (C:\GIT\xxx\frontend\xxx\main.js:375034:11) at destroyLView (C:\GIT\xxx\frontend\xxx\main.js:375182:5) at RootViewRef.destroy (C:\GIT\xxx\frontend\xxx\main.js:380895:5) at C:\GIT\xxx\frontend\xxx\main.js:394237:48 at Array.forEach (<anonymous>) at ApplicationRef.ngOnDestroy (C:\GIT\xxx\frontend\xxx\main.js:394237:27) at R3Injector.destroy (C:\GIT\xxx\frontend\xxx\main.js:377100:17)
Could you replace
ngOnDestroy(): void { this.LG.destroy(); this.lgInitialized = false; }
by
ngOnDestroy(): void { if (this.LG) { this.LG.destroy(); } this.lgInitialized = false; }
I have version 2.7.1 with Angular 15, but it also happens with 2.6.1