我想使用管道使用变量,在这种情况下,我有一个带有管道键的列对象,将在模板中使用。我怎样才能做到这一点?
columns = [
{
key: 'Amount',
name: 'Amount',
width: 'col-xs-1',
pipe: "number:'1.2-2'"
},
{
key: 'TransactionDate',
name: 'Transaction Date',
width: 'col-xs-1',
pipe: "date:'medium'"
}
];
transactions = [
{
"TransactionDate": "2018-04-27T14:55:30.2",
"Amount": 5,
}
];
我试图在模板迭代中使用column.pipe,但我得到模板解析错误
<tr *ngFor="let transaction of transactions; let counter = index">
<td *ngFor="let column of columns" class="{{ column.width }}">{{ transaction[column.key] | column.pipe }}</td>
</tr>
有什么建议吗? 提前谢谢!