JSON payload is coming back with the right data but I can't seem to display the right data to my table, The data is not showing in angular material component. I want to be able to table down the data I have in json response.
I am using Angular Material for the components of my application
code:
<mat-form-field appearance="outline">
<mat-label>Month</mat-label>
<input matInput [(ngModel)]="month">
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Year</mat-label>
<input matInput [(ngModel)]="year">
</mat-form-field>
<button (click)="getDepreciationList()" mat-raised-button color="primary">Load Property</button>
<!--Table-->
<table mat-table [dataSource]="propertySched" *ngIf='showTable' class="table-bg" mat-table>
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>Item ID</th>
<td mat-cell *matCellDef="let element"> {{element.id}} </td>
</ng-container>
<ng-container matColumnDef="itemDescription">
<th mat-header-cell *matHeaderCellDef>Item Description</th>
<td mat-cell *matCellDef="let element"> {{element.itemDescription}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</table>
tsfile code:
year : any = new Date().getFullYear();
month : any = new Date().getMonth() + 2;
depreciationListObj :Array<Object>;
displayedColumns = ['id']
showTable: boolean = false;
constructor(private depreciationsrv: DepreciationService) {}
ngOnInit(): void {
}
getDepreciationList() {
this.depreciationsrv.getForDepreciationList(this.year, this.month).subscribe((depreciationListObj:DepreciationDTO) => {
console.log(depreciationListObj);
this.showTable = !this.showTable;