如何在 mat-table 中设置预定义键

How can i set pre defined key in mat-table

我正在从 api 获取数据。我想以键值格式显示 mat table 上的数据。密钥是预定义的,密钥不是来自 api.

来自 api 我正在获取数据 image1

在垫子上 table 我想这样展示它:

mat table image

所以我试图让我的主要数据采用键和值格式。意思是

dataAddress = [
        {key: "Company Name", value: "Abuja Corp"},
        {key: "Company Address", value: "1-301, Sector 18,"},
        {key: "Email Address", value: "info@gmail.com"},
        {key: "Phone number", value: "9999999999"},
    ];

我试过这个:

interface Data{
    key:string;
    value:string;
}

const keys =[
    'Company Name',
    'Company Address',
    'Email Address',
    'Phone Number'
]

})
export class CompanyInformationComponent implements OnInit {
    currencies = [];
    dialogRef: any;
    header = [{name: "Company Information"}];
    //dataAddress:any;
    dataAddress = [
        
    ];
    dataSetting = [
        {id: 1, key: "Home/local currency", value: "Naira"},
        {id: 2, key: "International Currency", value: "USD"},
        {id: 3, key: "Auto-Post JV?", value: ""}
    ];
    displayedColumns: string[] = ['key', 'value'];
   // displayedColumnsSetting: string[] = ['key', 'value', 'actions'];

    constructor(
        private companyInformationService: CompanyInformationService) {
    }

    ngOnInit(): void {
        this.refresh();        
    }
 
    refresh() {
        this.getCompanyInformation();
    }

    getCompanyInformation()
    {
        
        const data1 ={};
        this.companyInformationService.getCompaniesInformationList().subscribe(data => {
            this.dataAddress = data.items;
            console.log("data",this.dataAddress);

           const newData: Data[] =[];

           for(const prop in this.dataAddress){
               newData.push({
                key:keys,
                value: this.dataAddress[prop]
               });
           }
        });
    }  

}

但是出现错误:

 Type 'string[]' is not assignable to type 'string'.ts(2322)
Untitled-1(2, 5): The expected type comes from property 'key' which is declared here on type 'Data'
const keys =[
    {prev:'name', to:'Company Name'},
    {prev:'address', to:'Company Address'},
    {prev:'email', to:'Email Address'},
    {prev:'phone', to:'Phone Number'},
];

const data: Data[] = [];
for (const d of this.dataAddress) {
    for (const k of keys) {
        data.push({ key: k.to, value: d[k.prev] });
    }
}