Hello everyone.
I’m trying to do a use of data binding quite particular.
I have 2 JSON files:
{
"river": {
"id": 1,
"name": "Thing 1",
"overall_quality": 3,
"extra_info": "",
"locations": [
{
"id": 2,
"thing_id": 1,
"lat": 22.12212,
"lon": -3.48485,
"town": "Bristol",
"zoom": 0.99,
"shop_id": 1,
"quality_id": 2
}
]
}
}
and:
{
"localShops": [
{
"id": 1,
"name": "Seter",
"link": "https:\/\/www.ser.co.uk",
"telephone": "0800 788 4884",
"email": "info@stwater.co.uk"
},
{
"id": 2,
"name": "Tter",
"link": "http:\/\/www.tter.co.uk",
"telephone": "0800 396 9120",
"email": "customerservices@tter.co.uk"
}
]
}
I have stored the second one in an array in order to display the name of the shop from the id in the locations file.
When I display the locations I do it as follows:
<ion-list>
<button ion-item *ngFor="#location of locations">
{{location.town}} - {{And here should be the name of the shop}}
<button primary clear item-right>
<ion-icon name="navigate"></ion-icon>
Start
</button>
</button>
</ion-list>
My first thought was trying to do it as
{{localShops[{{location.id}}].name}}
but it doesn’t work. I also tried other approaches like
{{localAuths}}+[{{location.id}}]+.name}}
but is not working either, as the only thing I retrieve is
[object Object],[object Object]
Any idea of how should I handle this so unorthodox approach for data binding?
Thanks.