Im trying to use Angular datatable with angular2. The code is similar to this
myArray: any;
function test() {
callService subscribe((response) => {
this.myArray = response['body'];
})
this.datatableOptions();
}
datatableOptions() {
this.dtOptions = {
order: [1, "desc"],
pagingType: "full_numbers",
pageLength: 100,
lengthMenu: [
[100, 150, 200, -1],
[100, 150, 200, "Todo"]
],
responsive: true,
rowCallback: function(row, data, index) {
var api = this.api();
$('td:eq(0)', row).html(index + (api.page() * api.page.len() + 1));
},
processing: true,
searching: true,
deferRender: true,
data: JSON.parse(JSON.stringify(this.myArray)),
columns: [{
targets: 0,
data: null
},
{
targets: 1,
data: 'A',
defaultContent: '-'
},
{
targets: 2,
data: 'B',
defaultContent: '-'
},
{
targets: 3,
data: 'C',
defaultContent: '-'
},
],
}
}
The problem: console.log(response['body']) has data, but datatable doesn´t show any data. So, what´s wrong in this code?