angular - Angular pipe - Angular Mat-Table - 如何修改管道以正确呈现数据?
问题描述
如何重写管道以便在 mat-table 中填充数据?基本上,我正在尝试理解和开发可重用的自定义表。为此,我有类似的数据结构,
[
{
name: 'xxxxx',
description: 'xxxxx',
obj: {
custId: 'xxxxx-01',
custName: 'xxxxx-dala',
adminName: 'xxxxx',
country: 'USA',
region: 'Texas',
}
}
]
这是我当前的界面
export interface Table{
name: string;
description: string
obj: Obj [];
}
export interface Obj{
custName: string;
custId: string;
country: string;
region: string;
}
@Pipe({
name: 'cleanData'
})
export class DataProps implements PipeTransform {
transform(object: any, keyName: string, ...args: unknown[]): unknown {
return object[keyName];
}
}
<td mat-cell *matCellDef="let element" >
{{element | cleanData: tableColumn.dataKey}}
</td>
解决方案
推荐阅读
- python - 当输入形状不同时,keras 中的迁移学习
- javascript - 如何用javascript隐藏类
- shell - Unix shell 脚本:日期格式语法
- android - Webview 谷歌登录不显示设备上的帐户
- google-apps-script - 如何将静态时间戳脚本 Google 工作表循环到所有工作表
- nginx - uwsgi 可以使用“真实”IP 运行吗?
- angular - 仅在首次登录时隐藏文本
- python-3.x - 如何定义给定函数的输入必须是类的变量(静态)
- r - R:如何在特定假设下将年度数据更改为月度数据?
- powershell - 关于 azure powershell、定义两次验证和磁盘创建的问题