dsy48837 2019-07-03 09:24
浏览 239

如何通过点击删除..?

I have one table content in which I have created view of it's list and performing the edit and deleting task on it.

I am trying it by calling in services the splice method and in the component it's service by id.

table.component.ts:

 delete(com) {
    this.service.DeleteUser(com);
    console.log(com);
}

table.component.html:

<a class="btn btn-outline-danger  btn-sm" (click)="delete(com.id)">Delete</a>

service:

 DeleteUser(index: number) {
    this.company.splice(index, 1);
    this.company_change.next(this.company.slice());
  }

I want to get delete button on working condition,company:Company[] list is been created by type model.

  • 写回答

2条回答 默认 最新

  • dongmai6666 2019-07-03 09:44
    关注

    Try this:

    replace the com.id with i in the click function delete

    <tr class="table-active" *ngFor="let com of company;  let i = index">
            <td>{{com.co_name}}</td>
            <td>{{com.co_profile}}</td>
            <td>{{com.co_address}}</td>
            <td>{{com.co_email}}</td>
            <td>
              <a class="btn btn-outline-secondary btn-sm" [routerLink]="['/table',com.id]">
                Edit
              </a>
              <a class="btn btn-outline-danger  btn-sm" (click)="delete(i)">Delete</a>
            </td>
          </tr>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器