【发布时间】:2018-01-27 04:45:36
【问题描述】:
我正在尝试通过单击 for 循环中该行中的按钮来删除特定行,但它会删除该表的所有行。
这是我的 HTML 代码:
<table id="mytable" class="table table-bordred table-striped">
<tbody id="del">
<tr *ngFor="let cart of modalData">
<td>
<div style="display:inline-flex;">
<div style="margin-left:10px;">
<p class="font_weight" style="font-size:13px;">{{cart.ExamName}}</p>
<p>{{cart.Categoryname}}|{{cart.CompanyName}}</p>
</div>
</div>
</td>
<td>
<div style="margin-top: 32px;">
<p class="font_weight" style="font-size:13px;"></p> <span class="font_weight" style="font-size: 13px;"> {{cart.Amount| currency :'USD':'true'}} </span> </div>
</td>
<td>
<div style="margin-top: 19px;">
<button class="button_transparent" (click)="Delete(cart)"> delete </button>
</div>
</td>
</tr>
<tr> </tr>
</tbody>
</table>
这是我的组件:
public loadData() {
let transaction = new TransactionalInformation();
this.myCartService.GetExamOrderForCart()
.subscribe(response => this.getDataOnSuccess(response),
response => this.getDataOnError(response));
}
getDataOnSuccess(response) {
this.modalData = response.Items;
}
这是我的删除方法:
public Delete(response) {
this.myCartService.updateExamOrder(response)
.subscribe(response => this.getDataOnSuccessForDelete(response),
response => this.getDataOnErrorForDelete(response));
}
请帮我做,如何从表中只删除一行?
【问题讨论】:
-
你的意思是从上到下一层一层?
-
你能发布你的删除方法吗?
-
public Delete(response) { this.myCartService.updateExamOrder(response) .subscribe(response => this.getDataOnSuccessForDelete(response), response => this.getDataOnErrorForDelete(response)); }这是我的删除方法
标签: javascript angular html-table