我正在使用角度材料表来显示数据并动态绑定表头和表数据。有没有办法动态格式化特定列的单元格内容?
例如,我如何格式化金额列的值右对齐?
我的代码如下:
<table mat-table [dataSource]="dataSource" class="" style="width: 100%;">
<ng-container [matColumnDef]="col" *ngFor="let col of displayedColumns; let i = index">
<th *matHeaderCellDef> {{displayedFields[i].name}}</th>
<td mat-cell *matCellDef="let element"> {{ element[col] }} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
我的数据就像
[
{
"REFERENCE_ID": "ENT201810637610",
"PRODUCT_TYPE": "IMPS",
"CUSTOMER_REFERENCE": "CUS12123",
"BENEFICIARY_NAME": "arun",
"DEBIT_ACCOUNT": "100002258062",
"AMOUNT": 342234,
"STAGE_CODE": "FULLFILMENT",
"STATUS_CODE": "NEW"
},
{
"REFERENCE_ID": "ENT201808820426",
"PRODUCT_TYPE": "IMPS",
"CUSTOMER_REFERENCE": "12121",
"BENEFICIARY_NAME": "Arun",
"DEBIT_ACCOUNT": "32423424",
"AMOUNT": 700,
"STAGE_CODE": "INITIATION",
"STATUS_CODE": "NEW"
}
]