I'm in a bind here. Working on refactoring the HTML of a rather messy pile of angular components and their templates.
The catch is that in one particular case, I can't have a parent element in the DOM. Right now, the template selector is set up as this:
<thisComponent *nIf="blah" [someParam]="hello"><thisComponent>
Which renders this in the DOM:
<thisComponent>
<div>Hello</div>
<div>World</div>
<thisComponent>
This is breaking the CSS we'd like to use and keep consistent with the rest of the content being rendered.
I'd like to have the above work without the parent thisComponent
element.
I was thinking something like this might work:
<ng-container thisComponent *nIf="blah" [someParam]="hello"></ng-container>
(and then change the selector to an attribute selector ala [thisComponent]
)
But it appears this does not work.
Is there a way to accomplish the above without the parent element rendering in the DOM?
Some more context. There's another duplicate question that suggests using an attribute selector, but the catch is you still need a parent element (with an attribute). Ideally, angular would allow that parent element to be an ng-container, which doesn't render a parent element. But that is not supported.
Why this is needed:
CSS likes a clean DOM structure and some features depend entirely on it...namely flex layouts. Flex layouts completely break when there are extra DOM layers between the flex container and the flex objects.