Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何从角度分析对象数组中的字符串?_Angular - Fatal编程技术网

Angular 如何从角度分析对象数组中的字符串?

Angular 如何从角度分析对象数组中的字符串?,angular,Angular,我有一个名为customer details的对象数组,其中conations country:id,country是customer表中与country表有关系的字段。目前,当通过反应式表单列出数据时,我在表单字段中获取id。我需要解析int并从子country表中获取名称 响应: accountsEmail: "s@s.com" address1: "b" country: 1 createdAt: "2020-05-05T05:08:54.858Z" createdBy: null del

我有一个名为customer details的对象数组,其中conations country:id,country是customer表中与country表有关系的字段。目前,当通过反应式表单列出数据时,我在表单字段中获取id。我需要解析int并从子country表中获取名称

响应:

accountsEmail: "s@s.com"
address1: "b"
country: 1
createdAt: "2020-05-05T05:08:54.858Z"
createdBy: null
deletedAt: null
deletedBy: null
fax: ""
id: 134
我想得到这个国家:1到阿富汗

国家名单答复

createdAt: "2020-04-02T12:35:52.205Z"
 id: 1
 name: "Afghanistan"
 updatedAt: "2020-04-02T12:35:52.205Z"

您可以使用这种方法

var obj={
帐户邮箱:“s@s.com",
地址1:“b”,
国家:1,
创建日期:“2020-05-05T05:08:54.858Z”,
createdBy:null,
deletedAt:null,
deletedBy:null,
传真:「,
身份证号码:134
}
var countryList=[
{createdAt:“2020-04-02T12:35:52.205Z”,
id:1,
名称:“阿富汗”,
更新日期:“2020-04-02T12:35:52.205Z”
}
]
obj.country=countryList.find(c=>c.id==obj.country).name

console.log(obj)
您是否有国家/地区列表,请分享其格式,并添加@ShlokNangia