我有一个返回此结果的函数:
{id: 20, dateCreation: 1517324655450, auteurCreation: "bel", dateModification: 1530544886148, auteurModification: "user", …}
auteurCreation:"bel"
auteurModification:"user"
coupesTechniquesDescription:Array(1)
0:{id: 15, hauteurReference: 2, commentaireReference: "test"}
length:1
__proto__
:Array(0)
dateCreation:1517324655450
id:20
我想将:coupesTechniquesDescription
保存在变量中,
目标是获取 coupesTechniquesDescription 列表并使用第一个索引
最佳答案
给你。从 res
中获取对象:
// define the variable above your constructor
private coupesTechniquesDescription;
constructor(...){
this.technicalservice.find(this.id).subscribe((res) => {
this.coupesTechniquesDescription = res.coupesTechniquesDescription[0];
console.log(this.coupesTechniquesDescription);
},
(err) => { console.log("Erreur"); });
}
关于javascript - 从 json feed Angular 4 中的表中检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51187216/