I want to make a structural directive named showWrapperIf
, which either keeps the whole element and children it sits on, or, when the condition is true
, removes the element (wrapper) it sits on, and takes all the children and keep it in the DOM.
So, the result of this
<div *showWrapperIf="true">
<h2></h2>
<p></p>
<any-component></any-component>
</div>
would be
<div>
<h2></h2>
<p></p>
<any-component></any-component>
</div>
but, if the condition
is false
, only the children need to be displayed. E.g:
<h2></h2>
<p></p>
<any-component></any-component>
I know I can do it with <ng-template>
and *ngIf
, but the wrapper has lots of children, it would double the size of the file and make it less readable.