Angular: ngOnChanges() not being called on child of dynamically created component

Vijay Pagare
Nov 15, 2022

--

I recently came across this problem and didn't find any straightforward solution — had to bang my head for several hours (and read through a lot of articles) to get past it — so here we are.

The comments in Anuglar's official github issue are not very helpful and locked due to inactivity — so I'm posting the solution here in case anyone (or future me) needs it.

The code snippet that worked for me (rather the solution I was trying to engineer vs the other ones):

Also, refer to this awesome article on dynamic components by Netanel Basal which helped me figure out the solution.

I can explain more on this but only if someone's hearing… so please comment and let me know if you're stuck somewhere. Cheers and happy coding! 🥳

--

--

Vijay Pagare
Vijay Pagare

Written by Vijay Pagare

Software Engineer | Frontend Developer | Open for opportunities