我想使呈现为多个表行的角度2中的TableRowsComponent。表中角度为2的组件中的行
我想在这样的一个模板来使用它:
<table class>
<tbody>
<table-rows *ngFor="#item of list" [someInput]="item"></table-rows>
</tbody>
</table>
(因此,“表行”将是这里的TableRowsComponent的选择)的TableRowsComponent的模板会是这样的:
<tr>
<td> foo </td>
<td> bar </td>
</tr>
<tr *ngIf="something">
....
</tr>
<tr *ngFor="..">
...
</tr>
如果我们做到这一点,那么结果是这样的:
<table class>
<tbody>
<table-rows>
<tr>
...
</tr>
<tr>
...
</tr>
</table-rows>
<table-rows>
<tr>
...
</tr>
<tr>
...
</tr>
</table-rows>
</tbody>
</table>
不幸的是,< table-rows>元素混淆了表格的渲染。如何解决这个问题呢?有没有办法让angular2不能渲染<表行>元素?
你可能想看看这个http://stackoverflow.com/questions/38463346/angular2-formgroup-inside-tr-child -component/38470631#38470631 –
感谢您的参考。这几乎是一个很好的解决方案,但是如果您检查plunkr,那么解决方案中的每个< tr > ... < /tr >都在其自己的< tbody > ... < /tbody > :( –