我正在使用 Angular-DataTables 6.0(可在此处找到https://l-lin.github.io/angular-datatables/#/welcome)并且我遇到了重复出现的问题。当添加或删除表项时,记录会在排序或搜索时消失或重新出现。这可能是因为添加/删除是从数据表外部发生的吗?
我尝试添加“datatable=”ng“”修复许多其他人建议的问题,但这并没有改变任何东西。我还尝试添加重新渲染功能,但在这种情况下,我遇到了无法解决的“对象取消订阅”错误。作为参考,可以在这里找到一些类似的问题:类似的例子包括:(Angular :对数据表进行排序后丢失数据)(对角度数据表中括号内的数字进行排序)(https://github.com/l-lin/angular-datatables /问题/852)
这是我的代码:
HTML:
<table datatable="ng" [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="table table-hover" id="t1">
<thead>
<tr>
<th>
<button id="b5">Asset ID</button>
</th>
<th>
<button id="b5">Employee ID</button>
</th>
<th>
<button id="b5">Asset Type</button>
</th>
<th>View</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let a of assets; let i = index">
<td>{{ a.assetID }}</td>
<td>{{ a.currentUser }}</td>
<td>{{ a.assetType }}</td>
<td><button id="button1" (click)="viewAsset(a)"><i class="fas fa-search"></i></button></td>
<td><button id="b2" class="btn" (click)="scrapAsset(a)" (mouseenter)="buttonHover(i)" (mouseleave)="buttonHoverLeave(i)"><i class="{{buttonIconArray[i].text}}"></i></button></td>
</tr>
</tbody>
</table>
-elsewhere in …Run Code Online (Sandbox Code Playgroud)