【发布时间】:2021-08-26 03:14:41
【问题描述】:
我在组件内有一个表格视图,其中包含使用 *ngFor 指令呈现的行。当用户单击特定行时,我想在该行下方显示一个子组件。以下是我的代码。
<tbody>
<ng-container *ngFor="let item of items" >
<tr (click)="expand(item)">
<td>{{item.name}}</td>
<td>{{item.title}}</td>
<td>{{item.description}}</td>
</tr>
<tr *ngIf="isexpanded(item)">
<app-item-comp [item]="item"></app-item-comp>
</tr>
</ng-container>
当我单击一行时,这将显示子组件 app-item-comp。但它的宽度与行的第一个元素相同,而不是占据整个窗口。我想查看这个具有整个表格宽度的子组件。我怎样才能做到这一点?谢谢。
【问题讨论】:
-
如果
app-item-comp'返回'一个td(th)元素,试试colspan attribute -
在我的子组件中,我有另一个表。
标签: html angular typescript