Issue
I have a table that displays the following values:
const COLS = [
{ value: "NumCheck", displayName: '#Check' },
{ value: "Date", displayName: 'Date' },
{ value: "Obj", displayName: 'Object' },
{ value: "Sum", displayName: 'Sum' }
];
And I want the Sum
value to be displayed in this format #.00
.
How can this be done if I have such a table?
<table mat-table class="tb" [dataSource]="dataSource">
<ng-container [matColumnDef]="column.value" *ngFor="let column of allCols;">
<th mat-header-cell *matHeaderCellDef>
{{column.displayName}}
</th>
<td mat-cell *matCellDef="let row">
{{column.value === 'Date' ? (row[column.value] | date : 'dd.MM.yyyy, HH:mm'): row[column.value]}}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
Solution
Use the number pipe
{{column.value === 'Date' ? (row[column.value] | date : 'dd.MM.yyyy, HH:mm'): ((column.value === 'Sum') ? (row[column.value] | number:'.2-2'):row[column.value])}}
Answered By - surendra kumar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.