The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Generate Angular 2 Components Programmatically with entryComponents

Generate Angular 2 Components Programmatically with entryComponents

4:12
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.
Watch this lesson now
Avatar
egghead.io

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.

Avatar
Iaroslav

Seems the plunker example doesnt work.

In reply to egghead.io
Avatar
Nicolas

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

Avatar
mrsoto

In this scenario, as usually is, the component creation responsibility is associated to the Angular app but in an scenario like GoldenLayout [https://www.golden-layout.com/tutorials/angular-complex.html] the A2App is not the driver one.

Is there away to bootstrap multiple applications having a root element as components are in this video?

What I do figure out to implement this portlets like app is to instantiate an application or module per each GoldenLayout widget.

Thanks in advance

In reply to egghead.io
Avatar
mrsoto

I found a solution. Define the component and module inside a factory method and define the selector as an expression. Both classes are clousore instances.

In reply to mrsoto
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?