The CSS solution works well, but it is not perfect:
:host { display: contents; }
This solution say to browser that the wrapper component tag must be ignored.
But this solution do no apply the right style if it is this:
table > :not(caption) > * > * { border-bottom-width: 1px; }
This CSS apply the border width to element in 3° descendant. For example:
tbody > tr > td
But if DOM structure contains the Angular wrapper, the 3° descendant is tr:
tbody > appMyTableRows > tr
To solve this issue I am using another solution: ng-container + ViewContainerRef.
Most complex but better solution
The solution is to draw the entire component inside a ng-template, then it will be rendered in caller component using ng-content.
How to draw component template:
<ng-template #bodyTempl>
<tr>
<td>This is</td>
<td>the content</td>
<td>of Component.</td>
</tr>
<tr>
<td>This is</td>
<td>the content</td>
<td>of Component.</td>
</tr>
</ng-template>
Then in Component code we must add something like this:
@ViewChild("bodyTempl") bodyTemplate: TemplateRef<any>;
As last step, we need to change how we use the component in template:
<table>
<thead>
<tr>
<th>head</th>
<th>head</th>
<th>head</th>
</tr>
</thead>
<tbody>
<tr>
<td>row 1</td>
<td>row 1</td>
<td>row 1</td>
</tr>
<app-my-table-tr #childComRef></app-my-table-tr>
<ng-content *ngTemplateOutlet="childComRef.bodyTemplate"></ng-content>
</tbody>
</table>
The HTML result shows the "app-my-table-tr" tag like child of TBODY, but it is empty. And the content of component will be injected like sibling of the component:
<table>
<thead>
<tr>
<th>head</th>
<th>head</th>
<th>head</th>
</tr>
</thead>
<tbody>
<tr>
<td>row 1</td>
<td>row 1</td>
<td>row 1</td>
</tr>
<app-my-table-tr _ngcontent-...></app-my-table-tr>
<tr>
<td>This is</td>
<td>the content</td>
<td>of Component.</td>
</tr>
<tr>
<td>This is</td>
<td>the content</td>
<td>of Component.</td>
</tr>
</tbody>
</table>
To a perfect solution, write this in CSS of Component, so the wrapper will not rendered:
:host { display: none; }
(source: https://blog.josematos.work/how-to-render-an-angular-component-without-any-wrapping-tag-5084c84e0a62)
[and]and you can applied to any html tag, e.g. a div