I have been using datatables for years inside a DurandalJS and KncokoutJS project.
We are now converting to use Angular 6.
If I define a table (below), how can I get the button click event to work? Specifically inside Angular, with a reference to the data of the row? In knockoutJs there was a way to "rebind" the HTML AFTER the server call. I cannot get this to work with Angular.
this.dtOptions = {
ajax: (dataTablesParameters: any, callback: any) => {
this.myService.myEndPoint(dataTablesParameters).
subscribe((resp: any) => {
this.myDataCollection = resp.aaData;
this.ref.detectChanges();
callback({
recordsTotal: resp.iTotalRecords,
recordsFiltered: resp.iTotalDisplayRecords,
data: resp.aaData
});
});
},
select: true,
order: [2, "asc"],
columns: [
{ data: null, defaultContent: 'details', orderable: false, class: 'details-control'},
{ data: null, orderable: false, },
{ data: "partNumber", orderable: true, },
{ data: "units", orderable: true },
{
title: "Display Name",
data: null,
orderable: true,
render: (data, type, full) => `<button (click)="testClick(data.id)">ClickMe</button>`
}
]
};