I have a json with events that I get it with this.$http.get from the backend. I have to output in the page event name, description, … and polygons(witch are locations).
Here in these polygons I have the name of the location, witch I don’t know how to output it with binding in the page.
GET /event
{
"errorCode": 0,
"errorMessage": null,
"events": [
{
"errorCode": 0,
"errorMessage": null,
"rid": "1",
"eventName": "ev1",
"description": "desc1",
"startDate": 1503262800000,
"endDate": 1503262800000,
"ownerId": 1,
"active": true,
"deleted": false,
"polygons": [
{
"errorCode": 0,
"errorMessage": null,
"rid": "1",
"name": "loc1",
"companyBranchId": 1,
"filePath": "file1",
"imagePath": "img1",
"color": "col1",
"active": true,
"deleted": false,
"links": []
}
],
"nrOfInvitees": 0,
"ids": [],
"visitors": [],
"links": []
},
{
"errorCode": 0,
"errorMessage": null,
"rid": "2",
"eventName": "ev2",
"description": "desc2",
"startDate": 1503262800000,
"endDate": 1503262800000,
"ownerId": 1,
"active": true,
"deleted": false,
"polygons": [
{
"errorCode": 0,
"errorMessage": null,
"rid": "2",
"name": "loc2",
"companyBranchId": 2,
"filePath": "file2",
"imagePath": "img2",
"color": "col2",
"active": true,
"deleted": false,
"links": []
}
],
"nrOfInvitees": 0,
"ids": [],
"visitors": [],
"links": []
},
]
}
Getting the event name, description or date was easy but when I try to output the polygons.name I don’t get anything in the page.
<div class="event-title">
<span>{{event.eventName}}</span>
</div>
<div class="event-address">
<span><i class="ti-location-pin"></i> {{event.polygons.name}}</span>
</div>
I get the data in this above Event.vue from Events.vue
<app-event v-for="event in events" :event="event" :key="event.rid"></app-event>
I tried to do in the child component:
{{JSON.stringify(event.polygons.name)}}
but I get only the first location name from the whole list, so in the page I get only one event displayed.
When I tried
{{event.polygons.length}}
the output was 1.
I know that in PHP is something like 2 for .. as .. && .. as ..
.
in vuejs will be
<app-event v-for="event in events && polygon in event.poligons" :event="event" :key="event.rid"></app-event>
but doesn’t work.
Please, someone, can tell me how to get in the child page the polygons name?