首页 > 解决方案 > 数据表按钮单击角度 4

问题描述

我在 Angular 4 应用程序中使用数据表。在将数据附加到表时,我使用不同的按钮执行不同的操作

下面是我的代码:

{
  data: 'iUserId',
  defaultContent: "-",
  "mRender": function (data, type, full) {
       return '<button class="btn btn-danger btn-xs btn-flat" (click)="deleteUserConfirm('+data+')" title="Delete" data-toggle="tooltip"><i class="fa fa-times"></i></button>'
   }
},

我创建了 deleteUserConfirm 方法来对删除按钮单击执行一些操作,但此按钮不调用 angular 方法。如果我不使用数据表,按钮可以正常工作。有没有其他方法可以从数据表中调用 angular 4 方法。

标签: angularbuttondatatableclick

解决方案


将您的 HTML 更改为,

'<button class="btn btn-danger btn-xs btn-flat" (click)="deleteUserConfirm(data)" title="Delete" data-toggle="tooltip"><i class="fa fa-times"></i></button>

推荐阅读