I'm trying to get an angular directive to repeat inside a <tr>
. Without the directive, the code is
<tr *ngFor='let cluster of clusters'>
<td style='display: flex; flex-direction: column; width: 40%; min-width: 300px;'>
<span>{{ cluster.Name }}</span>
<span>{{ cluster.StatusMessage }}</span>
</td>
<td style='width: 100%;'>
...
</td>
</tr>
And looks like
When I refactor the directive, I lose the <tr>
formatting. The refactored code is
<tr *ngFor='let cluster of clusters'>
<cluster-row [name]='cluster.Name' [statusMessage]='cluster.StatusMessage'></cluster-row>
</tr>
The cluster-row component code is:
<td style='display: flex; flex-direction: column; width: 40%; min-width: 300px;'>
<span>{{ name }}</span>
<span>{{ statusMessage }}</span>
</td>
<td style='width: 100%;'>
...
</td>
It works, but the <tr>
formatting goes away.
The developer tools show a <tr>
with a <cluster-row>
nested in it, and two <td>
s nested in that, as I would expect.
<tr>
can't contain a<cluster-row>
element.You can use an attribute selector instead like
with
The component or directive then is the
<td>
, therefore you can't repeat it inside the components templatecan just be added to