【发布时间】:2018-05-24 12:58:34
【问题描述】:
大家好,我在删除问题表中的行表时遇到了一些麻烦。
这是我在 component.ts 中的 deleterowtable 函数
deleteQuestions(questionsId: number) {
this.questionerDetails.removeAt(1);
}
这是我的组件 html
<!--qeustion input-->
<div formArrayName="questionerDetails" class="rap">
<table id="myTable" align="center" class="table table-bordered">
<tr><th>Questions</th><th>Actions</th></tr>
<tr *ngFor="let questions of questionerDetails.controls; let i=index" [formGroupName]="i">
<td><input style="width:100%;" formControlName="questionDetail" class="form-control" placeholder="type your questions here" /></td>
<td align="center">
<button (click)="deleteQuestions()" type="button" class="btn btn-success bc"><i class="fa fa-trash"></i></button>
</td>
</tr>
</table>
</div>
我的麻烦是我只能删除行表的最后一个索引或第一个索引。
示例:我有 5 行表 [0]、1、[2]、[3]、[4],我想删除编号 1 行被删除,然后我删除编号 [2] .所以行表有 [0],[4]。
选择行时如何删除行?
谢谢。
【问题讨论】:
-
你错过了
i里面的deleteQuestions()吗? -
是的,没错,我在 deleteQuestions(i) 中缺少 i
标签: angular