Recently I was looking at official release information about Angular 9 and figured out that Angular team have decided to deprecate entryComponents array which was crucial part of NgModule for creation of dynamic components like modal, advertisement banners etc. If you want to read about his deprecation you can check it here.

In versions before Angular 9 if we tried to create any component that is not party of entryComponents dynamically we used to get following error.

No component factory found for ModalComponent. Did you add it to @NgModule.entryComponents?

To understand this, we need to understand why Angular needed entryComponents array separately before Angular 9 to create these components dynamically. The reasons are following.

  1. If we read the error carefully, it is complaining about a missing factory. The components which had their selector in templates, Angular used to create NgFactories.
  2. Because Dynamic components were created with ComponentFactoryResolver without having any selector in template, Angular didn’t used to create Factories for them.
  3. entryComponents was an array of components which was used to inform Angular about such components, so that it could provide their NgFactory at runtime.

So now we understand, why Angular needed entryComponents array till version 8. But what happened from version 9 that made it unnecessary to use entryComponents array?

#web #javascript #framework #typescript #angular

Bye Bye Entry Components (Angular 9 and onward)
15.50 GEEK