【发布时间】:2022-11-02 02:48:11
【问题描述】:
需要您的帮助才能访问数组中对象的特定值。 我想在对象 NumberR 中显示他们关键小时的每个值。 并在我的 Angular 前台显示上午 11 点和晚上 7 点。 API 返回的 Json:
{
"reservations": {
"reservationInfo": [
{
"roomStay": {
"arrivalDate": "11am"
},
"WeatherR": {
"sound": "cloudy"
},
},
{
"roomStay": {
"arrivalDate": "7pm"
},
"WeatherR": {
"sound": "cloudy"
},
}
]
}
}
app.component.ts
searchForReservation() {
alert('hello');
this.http.get('/api/searchForReservation').subscribe((res) => {
this.ddataIno = res;
console.log('MY DATA', this.ddataIno);
this.unique = this.ddataIno.reservations.reservationInfo.map(
(e) => e.roomStay.arrivalDate
);
});
}
组件.html
<div class="test">
<p>Arrival Date:</p><p>{{this.date}}</p>
</div>
【问题讨论】:
-
您只想可视化小时数,对吗?
标签: json angular typescript