Проблема
Тип «Person []» не может быть назначен типу «ColumnSettings []».
Тип "Person" не имеет общих свойств с типом "ColumnSettings".ts(2322)
Ожидаемый тип исходит из свойства «столбцы», которое объявлено здесь для типа «Настройки».
я следил за http://l-lin.github.io/angular-datatables/#/basic/server-side-angular-way
проблема возникла после добавления json datatable.
Класс человека
export class Person {
id: number;
first_name: string;
last_name: string;
}
Угловой код
publicDeals: Person[] = [];
ngOnInit(): void {
const that = this;
this.abc();
console.log(this.publicDeals);
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: 2,
serverSide: true,
processing: true,
ajax: (dataTablesParameters: any, callback) => {
that.httpClient
.post<DataTablesResponse>(
this.api_url,
dataTablesParameters, {}
).subscribe(resp => {
that.persons = resp.data;
//console.log(resp);
callback({
recordsTotal: resp.recordsTotal,
recordsFiltered: resp.recordsFiltered,
data: [],
});
});
},
columns: that.publicDeals,
};
}
abc() {
return this.service.apifunc()
.subscribe(persons => {
this.testts = TABLE_FIELDS;
TABLE_FIELDS.forEach(element => {
this.publicDeals.push(element);
});
this.dtTrigger.next();
});
}
JSON-данные
TABLE_FIELD: [
{
data: "id"
},
{
data: "first_name"
},
{
data: "last_name"
}
]
не может добавить json в столбцы в datatable.
любая помощь приветствуется.