백엔드 (api)에서 json 데이터를 얻고 있습니다. 그리고 이것을 ngFor로 표시하고 싶습니다. 콘솔에서 "다른 지원 개체 '[개체 개체]'를 찾을 수 없습니다 . " 와 같은 오류 메시지가 나타납니다 .
나중에 나는 이것을 시도했다.
@Pipe({
name: 'mapToIterable'
})
export class MapToIterable implements PipeTransform{
transform(map: {}, args: any[] = null): any {
if (!map)
return null;
return Object.keys(map)
.map((key) => ({ 'key': key, 'value': map[key] }));
}
}
그리고 내 관점에서 :
<li *ngFor="let detail of getEventDetails | mapToIterable">
Creator Email: {{detail.creator.email}}
</li>
이번에는 오류가 발생하지 않았지만 표시 값이 없습니다. {{detail.creator.email}}
백엔드의 데이터
{
"banner_image": null,
"categories": [],
"creator": {
"email": "[email protected]",
"first_name": "Prince",
"gender": true,
"id": 15,
"last_name": "Odame",
"subscribed_categories": [],
"watchlist": []
},
"creator_id": 15,
"description": "Learn how to install solar panels in 3 days and make real money all your lifetime",
"faqs": [],
"id": 6,
"is_verified": true,
"max_tickets_per_user": 1,
"shows": [
{
"address": "Engineering Auditorium, College of Engineering, KNUST, Kumasi",
"city": "Kumasi",
"country": "Ghana",
"end_time": "2016-08-03T14:30:00+00:00",
"event_id": 6,
"id": 5,
"is_online": false,
"start_time": "2016-08-01T08:30:00+00:00",
"state": "Ashanti",
"ticket_types": [],
"venue": "Engineering Auditorium"
}
],
"tags": [],
"title": "Solar Panels Installation Workshop"
}
미리 감사드립니다
이 작업을 수행하고 싶을 것입니다.
<li>Creator Email: {{getEventDetails.creator.email}}</li>
그리고 어레이의 경우 :
<li *ngFor="let show of getEventDetails?.shows">
Show ID: {{show.id}}
</li>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다