I am currently utilizing Angular Material Table version 8.2.3 to generate multiple tables from a TypeScript definition. The majority of these tables are related to numerical data, requiring me to display totals in the footer section. However, I am facing an issue as the examples provided on the official material page only showcase single-column tables and do not address how to handle calculations for multiple columns. I am seeking a solution to dynamically calculate the sum of a column. Below is the code snippet that I have attempted unsuccessfully:
https://i.sstatic.net/axPZp.png
<table mat-table [dataSource]="dataSource" matSort matSortActive="Date" matSortDisableClear="true">
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ column.header }}</th>
<td mat-cell *matCellDef="let row">{{ column.cell(row) }}</td>
<td mat-footer-cell *matFooterCellDef> {{this.dataSource.data.reduce((data, val) => data+= val.cell(row), 0) </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
</table>