Issue
Recently after updating my angular cli from 16 to 17 I have been facing performance issues and I had no idea what is SSR and prerendering so I left them enabled. But the root cause was ssr.
After installing materialize-css I was getting an error M is not defined. Then I imported it from materialize-css.
Again I was getting an error window is not defined
Solution
Where using Server side rendering (SSR) and/or prerender, the app will run on a node environment where the global window
doesn't exist.
If you want to keep using SSR/prenrender and still access window
you can use afterNextRender()
which will be invoked on the browser side only (the callback will be run outside the Angular zone, you also might need ngZone.run()
.)
Answered By - Matthieu Riegler
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.