【发布时间】:2017-10-09 09:58:36
【问题描述】:
我有这个嵌套的 json,我从我的服务获取调用
{
"id": "7979d0c78074638bbdf739ffdf285c7e1c74a691",
"seatbid": [{
"bid": [{
"id": "C1X1486125445685",
"impid": "12345",
"price": 0,
"adm": {
"native": {
"link": {
"url": "http: //i.am.a/URL"
},
"assets": [{
"id": "001",
"required": 1,
"title": {
"text": "Learn about this awesome thing"
}
}],
"imptrackers": ["https://trks.c1exchange.com/trk/c?pid=123&et=i&profileid=123&siteid=12345&adslot=AUM&adsize=300x250&imprtype=IMAGE&cpm=0.0&dspcid=834&rndid=368997882&adomain=[c1exchange.com]&urid=8787893965303118897&uimprid=2063341746607836879&urespid=0"]
}
},
"adomain": ["c1exchange.com"],
"cid": "834"
}]
}],
"cur": "USD"
}{
"id": "7979d0c78074638bbdf739ffdf285c7e1c74a691",
"seatbid": [{
"bid": [{
"id": "C1X1486125445685",
"impid": "12345",
"price": 0,
"adm": {
"native": {
"link": {
"url": "http: //i.am.a/URL"
},
"assets": [{
"id": "001",
"required": 1,
"title": {
"text": "Learn about this awesome thing"
}
}],
"imptrackers": ["https://trks.c1exchange.com/trk/c?pid=123&et=i&profileid=123&siteid=12345&adslot=AUM&adsize=300x250&imprtype=IMAGE&cpm=0.0&dspcid=834&rndid=368997882&adomain=[c1exchange.com]&urid=8787893965303118897&uimprid=2063341746607836879&urespid=0"]
}
},
"adomain": ["c1exchange.com"],
"cid": "834"
}]
}],
"cur": "USD"
}
问题是我想在我的组件中使用它而没有相同的数据模型
目前在我的组件中
ngOnInit() {
this.weatherService.getPocData().subscribe( res => {
this.openRtbResponse = res.openRtbResponse;
});
}
在我的模板中
{{openRtbResponse | json}}
我可以访问相同的。
但是现在当我想像这样访问嵌套值时,它给出了 undefined like
this.openRtbResponse.seatbid[0].bid[0].adm.native.assets[0].id
它会抛出错误。
没有数据模型我不能使用json值
【问题讨论】:
-
我遇到了同样的问题,我通过将 var 中的组件的单个值发送到 HTML 来管理。
标签: angular