Когда я делаю консоль
показать массив: -
Теперь он работает нормально, когда этот массив показывает
console.log (this.test) показывает
0: {data: "id", mData: "id"}
1: {data: "firstname", mData: "firstname"}
2: {data: "lastname", mData: "lastname"}
ngOnInit(): void {
const that = this;
const columns_data = this.getContacts();
this.test = this.persons;
console.log(this.persons);
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: 4,
serverSide: true,
processing: true,
searching: false,
ajax: (dataTablesParameters: any, callback) => {
that.http
.post<DataTablesResponse>(
'http://localhost/api/listregister.php',
dataTablesParameters, {}
).subscribe(resp => {
that.persons = resp.data;
callback({
recordsTotal: resp.recordsTotal,
recordsFiltered: resp.recordsFiltered,
data: []
});
});
},
columns: this.test
};
}
getContacts(): void {
this.personService.getregistercolumns()
.subscribe(
persons => {
persons.forEach((line, index) => {
this.persons.push(line);
});
});
}
}