Generate Angular 2 Components Programmatically with entryComponents

Share this video with your friends

Send Tweet

You can generate Angular 2 components using a combination of ViewContainer and ComponentFactory, but you must always remember to add the components you want to generate to your list of entryComponents otherwise the compiler will optimize the component class out of your project.

Nicolas
Nicolas
~ 8 years ago

Would love Angular2 CheetSheets! Any plans for this in the future? It's hard to remember everything...

AlankarKumar
AlankarKumar
~ 4 years ago

I wasn't able to create the component in the ngAfterContentInit() lifecycle hook rather had to use ngAfterViewInit()