I have problem. Angular is sometimes showing error ERROR TypeError: Cannot read properties of undefined (reading 'onDestroy')
I am getting this error when I am running ng serve, but if I use angular universal, then page is sometimes loading properly and sometimes it is showing same error. I found out, that this error started when I started making modularization of my app.
Angular version 13.3
I found a solution for this issue; it is hard and not typical bug. It happens if you don't finish modularizing your code, where part of code you are using as modules and part as component imports.
Components that aren't modularized and used in app.component.html different than
are causing this error.
In my case, it was:
What is the issue?
If you have this error, and you add to navbar f.e.
<div></div>and then remove it app works normally.What is the solution?
You have to modularize all components used in app.component.html properly.