I have json response like, Im trying to iterate over json response but it is giving errors
I don't know if angular2 don't suport iteration like this as I'm new to angular2
serive call
return this.http.post(this.url,params)
.map(res => res.json())
Assigning response to travelGuides
.subscribe(travelGuides => {
this.travelGuides = travelGuides.resultData;
}
JSON
{
"resultCode": 1,
"resultData": {
"TravelGuide": [
{
"Help": "TravelGuide",
"IsDocument": "1",
"EventType": "Success",
"Category": "HOTEL",
"SupplierType": "SUPTYPE-0-0-11",
"HotelSrno": "HOTEL-0-0-62",
"Name": "Radisson Blu Plaza Bangkok",
"Optional": "0",
"Fileupload1": "hotel.jpg",
"FileUpload1Path": "/Documents/MasterData/HOTEL/HOTEL-0-0-62/hotel.jpg"
},
{
"Help": "TravelGuide",
"IsDocument": "1",
"EventType": "Success",
"Category": "HOTEL",
"SupplierType": "SUPTYPE-0-0-11",
"HotelSrno": "HOTEL-0-0-62",
"Name": "Radisson Blu Plaza Bangkok",
"Optional": "0",
"Fileupload1": "hotel.jpg",
"FileUpload1Path": "/Documents/MasterData/HOTEL/HOTEL-0-0-62/hotel.jpg"
}
],
"TravelGuide_Img": [
{
"Help": "TravelGuide_Img",
"IsDocument": "0",
"EventType": "Success",
"Category": "HOTEL",
"Name": "hotelimage.jpg",
"TextoverImg": "Radisson Blu ",
"Textbox2": "/Documents/MasterData/HOTELIMG/HOTELIMG-0-0-1",
"AltText": "Radisson Blu ",
"path": "/Documents/MasterData/HOTELIMG/HOTELIMG-0-0-1/hotelimage.jpg",
"ImageCategoryName": "IMGCATG",
"HotelName": "Radisson Blu Plaza Bangkok",
"ImageSize": "Medium",
"ImageResolution": "IMGSIZE-0-0-1",
"ImageCategory": "IMGCATG",
"Hotel": "HOTEL-0-0-62",
"ImageSize_srno": "IMGSIZE-0-0-1",
"ImageResolution1": "RESOLUTIO-0-0-1"
},
{
"Help": "TravelGuide_Img",
"IsDocument": "0",
"EventType": "Success",
"Category": "HOTEL",
"Name": "hotelimage.jpg",
"TextoverImg": "Text Over Image",
"Textbox2": "/Documents/MasterData/HOTELIMG/HOTELIMG-0-0-2",
"AltText": "Text Over Image",
"path": "/Documents/MasterData/HOTELIMG/HOTELIMG-0-0-2/hotelimage.jpg",
"ImageCategoryName": "IMGCATG",
"HotelName": "Pullman Bangkok Hotel G",
"ImageSize": "Medium",
"ImageResolution": "IMGSIZE-0-0-1",
"ImageCategory": "IMGCATG",
"Hotel": "HOTEL-0-0-63",
"ImageSize_srno": "IMGSIZE-0-0-1",
"ImageResolution1": "RESOLUTIO-0-0-2"
}
]
}
}
here is *ngFor im trying
<div *ngFor="let travelguide of travelGuides">
{{travelguide.TravelGuide.Category}}
</div>
but getting this
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
also tried
<div *ngFor="let travelguide of travelGuides.TravelGuide">
{{travelguide.Category}}
</div>
for this getting error
Cannot read property 'TravelGuide' of undefined