响应机构;
[
{
"professionalId": {
"cib_code": "30003",
"thirdPartyId": "RS30004"
},
"nationalIdentifier": "984538926",
"nationalIdType": "SIREN"
},
{
"professionalId": {
"cib_code": "30003",
"thirdPartyId": "RS30008"
},
"nationalIdentifier": "944316926",
"nationalIdType": "SIREN"
}
]
通过使用来自DB的休息调用获取json响应:
this.thirdpartyServices.getThirdparties().subscribe(data=>this.thirdpartyapis$=data);
在**thirdpartyapis**
对象
但我想要另一个可以包含这些数据的对象,如
[
{
"cib_code": "30003",
"thirdPartyId": "RS30004"
"nationalIdentifier": "984538926",
"nationalIdType": "SIREN"
},
{
"cib_code": "30003",
"thirdPartyId": "RS30008"
"nationalIdentifier": "944316926",
"nationalIdType": "SIREN"
}
]
想要在Typscript中映射我的数据,以便在Html中使用相同的对象来显示Grid表格中的数据 请使用angular 2 Typescript
建议答案 0 :(得分:0)
也许你可以使用解构,
this.thirdpartyServices.getThirdparties()
.map(each => {
let { nationalIdentifier, nationalIdType } = each;
return {
...each.professionalId,
nationalIdentifier,
nationalIdType
};
})
.subscribe(data => {
this.thirdpartyapis$ = data;
});
您也可以从
导入'map'import 'rxjs/add/operator/map';