【发布时间】:2016-11-16 20:23:19
【问题描述】:
我正在玩 angular 2(第一天;))。
我正在使用一个显示 tr 的组件,而另一个将在其中重复 tr 的组件。
<h3>Sensor list</h3>
<a (click)="refreshSensors()" class="btn btn-primary">Escanear Sensores</a>
<table class="table">
<thead>
<tr>
<th>Sensor</th>
<th>Description</th>
</tr>
</thead>
<sensor-list [sensors]="sensors"></sensor-list>
</table>
然后,在传感器列表中:
<h3>Sensor list</h3>
<a (click)="refreshSensors()" class="btn btn-primary">Escanear Sensores</a>
<table class="table">
<thead>
<tr>
<th>Sensor</th>
<th>Description</th>
</tr>
</thead>
<sensor-list [sensors]="sensors"></sensor-list>
</table>
当 ngFor 正确地重复 tr 时,我在我的 html 中得到了一个标签,导致表格无法正常显示:
<table class="table">
<thead>
<tr>
<th>Sensor</th>
<th>Description</th>
</tr>
</thead>
<sensor-list><tbody><!--template bindings={}--><tr>
<td>R2D2</td>
<td>Description of r2d2</td>
</tr><tr>
<td>C3PO</td>
<td>Description of c3po</td>
</tr></tbody></sensor-list>
</table>
我必须指定要在组件中显示的标签吗?用角度做这件事的正确方法是什么?
【问题讨论】:
-
我在您的代码中没有看到您的 ngFor 用法。
-
不清楚你想说什么...
-
我认为
sensor list的模板不对 ;-)
标签: angular