I am using angular material table 8.2.3. I have a lot of tables that are generated from a definition in the typescript. Most of the tables have to do with numbers so I have to show totals on the footer. Problem is that the material table examples in the material page have only one column and it does not show how to deal with multiple columns. I am looking for a way to dynamic calculate the sum of a column. I have the following code but it does not execute:
<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>