Items only display on table, when I click on the table.
When first time loading the page, the table is empty. I don't know why.
I retrieve the data from Rest-API Cloud Blobstorage and then I fill the empty Array.
here is the code:
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
Here I export interface PeriodicElement
//name of table column
export interface PeriodicElement {
timestamp: string; //need to be declared as string, angular table module requires it
key: string;
value: number;
}
export class TableComponent implements OnInit {
displayedColumns: string[] = ['timestamp', 'key', 'value'];
ELEMENT_DATA: PeriodicElement[] = new Array<PeriodicElement>();
dataSource = new MatTableDataSource<PeriodicElement>(this.ELEMENT_DATA);
data_array: Array<JsonSchema> = [];
@ViewChild(MatSort, { static: true }) sort: MatSort; //sort data
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; //for displaying data in the tables
constructor( privat DataStreamService: DataStreamService) {}
ngOnInit(): void {
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.DataStreamService.getContents().then(results => {
this.data = results
......
....
....cut code ....
this.ELEMENT_DATA.push(...tabledata)
}
On Browser View, when Table is rendered. when I click on items per page data loads, before that it shows an empty table.
maybe you guys know how to fix it. I spend days and didn't find the problems. Many thanks in advance