以下是服务电话
this.http.post(this.apiurl, {'user': this.user}, { responseType: 'json' })
.subscribe((data) => {
this.myRequests = JSON.stringify(data);
const requests = JSON.parse(this.myRequests);
this.Items = requests.filter(function(o) {
return o.detail;
});
},
err => {
console.log(err);
});
}
以下是从服务调用收到的响应:
Array [ {…}, {…} ] --> This is the array of object
下面是数组内容:
0: Object { detail: {'id':'1', 'type': 'service1'} }
1: Object { detail: {'id':'2', 'type': 'service2'} }
下面是 HTML
<ul>
<li *ngFor="let each of Items">
{{each.request_id}}
</li>
</ul>
访问该detail.id
属性
<ul *ngFor="let each of Items">
{{each.detail.id}}
</ul>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句