问题
类型“Person[]”不可分配给类型“ColumnSettings[]”。
“Person”类型与“ColumnSettings”类型没有共同的属性。ts(2322)
预期的类型来自属性 'columns',它在类型 'Settings' 上声明
我已经关注了http://l-lin.github.io/angular-datatables/#/basic/server-side-angular-way
附加 json 数据表后出现问题。
人物类
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 附加到数据表中的列中。
任何帮助都是最受欢迎的。