Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Angular插入表格行_Javascript_Angular - Fatal编程技术网

Javascript 如何使用Angular插入表格行

Javascript 如何使用Angular插入表格行,javascript,angular,Javascript,Angular,嘿,天使巫师 我正在从事Angular版本4.0.0的项目 我的应用程序组件模板中有以下结构: <table> <thead> <th>ID</th> <th>Label</th> <th>Action</th> </thead> <tbody> <ng-container *ngFor="let item of items">

嘿,天使巫师

我正在从事Angular版本4.0.0的项目

我的应用程序组件模板中有以下结构:

<table>
  <thead>
   <th>ID</th>
   <th>Label</th>
   <th>Action</th>
  </thead>
  <tbody>
    <ng-container *ngFor="let item of items">
      <tr app-vcr [item]="item"></tr>
    </ng-container>
  </tbody>
</table>
<td>{{item.id}}</td>
<td>{{item.label}}</td>
<td><button (click)="viewDetails()">Details</button></td>
<tr>
 <td colspan="99">
  <div>
   {{item.details}}
  </div>
 </td>
</tr>
我遇到的问题是,当我单击“查看详细信息”按钮时,它会插入详细信息组件,但它会像这样插入它:

<app-vcr-details> <--- ** this gets inserted, which is breaking the table **
 <tr>
  <td colspan="99">
    <div>
      Show the item details here!
    </div>
  </td>
 </tr>
</app-vcr-details>

我建议不要为表行使用组件,而是为整个表使用组件

<app-vcr-details> <--- ** this gets inserted, which is breaking the table **
 <tr>
  <td colspan="99">
    <div>
      Show the item details here!
    </div>
  </td>
 </tr>
</app-vcr-details>
<div> <--- ** this gets inserted, which is also breaking the table **
 <tr>
  <td colspan="99">
    <div>
      Show the item details here!
    </div>
  </td>
 </tr>
</div>