【发布时间】:2021-02-13 15:32:53
【问题描述】:
我希望从下面的 JSON 中获取详细信息“联系人”。
{
"id": "65664546",
"name": "Employee 1",
"contacts": [
{
"id": "56546564",
"firstName": "James",
"lastName": "Carter",
"email": "carter101@google.com"
},
{
"id": "565465644",
"firstName": "Simon",
"lastName": "Deol",
"email": "simon505@google.com"
}
]
}
下面是我定义的接口:
export interface employee {
id: string;
name: string;
contacts: contact[];
}
export interface contact {
firstName: string;
lastName: string;
email: string;
}
请您指教,它的 Httpget 方法和 subscribe 方法是什么样的。
【问题讨论】:
-
多个员工,所以多个联系人数组.. 你喜欢它吗?或者你想知道如何显示它?
-
嗨 MikeOne,我想访问单个选定员工的联系人。谢谢
-
@PratikSurani 请检查我的答案,让我知道它是否适合您。也让我寻求进一步的帮助。最美好的祝愿:-)
-
我正在寻找 get 和 subscribe 方法来获取这些数据并显示在组件模板中
-
@PratikSurani 我已经更新了我的答案,请立即查看。 :-)
标签: angular typescript