Compile the template before projecting the content. Dynamic design?

In my project, I meet several times on the same problem, and yet I could not find the right solution. I suspect this is part of the problem , but it sounds to me like a normal normal use case.

Many times I have a component with a template, for example: <my-component><ng-content></ng-content></my-component> where somewhere in the projected content it tries to get an instance of <my-component> . This just doesn't work, because the projected component is resolved before the <my-component> compilation.

This makes things impossible such as having custom form components when applying NgForm to them. As I illustrate in this plunkr . That sounds pretty standard to me.

Is there a way around this without having to explicitly apply my-component in the parent component?

+1
source share

All Articles