How do I implement my own version of ng-container
so I can use this:
<my-component ...>...</my-component>
instead of this:
<ng-container my-directive ...>...</ng-container>
I am struggling to find how ng-container
is implemented - maybe it is built directly into the compiler instead of as a separate directive? Is it possible to use Renderer2
to get rid of the host element?
I want a neat way to create wrapper components that do not introduce Angular host element noise in the final HTML. <ng-container my-directive>
would work, but is tedious and ugly. I don't want to use <div my-directive>
because that requires me to know that the component is a div
(this becomes a lot more crucial once we consider nesting wrapper components inside wrapper components).
Related questions with more backgound:
Correct way to implement wrapper components in Angular 4?
Angular 2 invisible component container
Aucun commentaire:
Enregistrer un commentaire