我有问题,更新数据数组(FileDto)后,数据表中没有可见的更改
我已经将睾丸放入ngFor中,并且可以正常工作。
在html中:
<ngx-datatable
class="material striped"
[rows]="fileDtos"
[columnMode]="'force'"
[rowHeight]="'auto'"
[messages]="gridMessages"
>
<ngx-datatable-column name="name" >
<ng-template let-column="column" ngx-datatable-header-template>
<strong>{{ 'FILES.NAME' | translate}}</strong>
</ng-template>
</ngx-datatable-column>
</ngx-datatable>
Typescriptfile:
loadFiles(): void {
this._fileService.getFiles(this.auftragId, false).subscribe(files => {
this.fileDtos = files;
this._fileService.getExcelFiles(this.auftragId).subscribe(filesexcel => {
if ( filesexcel) {
filesexcel.forEach(item => {
this.fileDtos.push(item);
});
}
});
});
}
数据对象:
export class FileDto {
name: string;
iconUrl: string;
extension: string;
created: Date | string;
modified: Date | string;
}
我没有错误消息,也没有在数据表中显示任何数据。知道为什么吗?
样本数据:
{name: "Filename1.xlsm", iconUrl: null, extension: "", created: "2019-03-12T13:37:25.973", modified: "0001-01-01T00:00:00"}
{name: "Filename2.xlsm", iconUrl: null, extension: "", created: "2019-03-12T12:13:53.847", modified: "0001-01-01T00:00:00"}
{name: "Filename3.xlsm", iconUrl: null, extension: "", created: "2019-03-12T13:37:25.973", modified: "0001-01-01T00:00:00"}
答案 0 :(得分:1)
感谢@sgrillon提供的关于“订阅”的提示很糟糕。现在工作正常。
这是我用forkJoin解决的方法:
forkJoin(
this._fileService.getFiles(this.auftragId, false), this._fileService.getExcelFiles(this.auftragId)
).subscribe((files) => {
this.fileDtos = files[0].concat(files[1]);
});