Hi I have list with items. Like this:
// Some fake testing data
var chats = [{
id: 0,
name: 'Ben Sparrow',
lastText: 'London',
face: 'img/ben.png'
}, {
id: 1,
name: 'Max Lynx',
lastText: 'Paris',
face: 'img/max.png'
}, {
id: 2,
name: 'Adam Bradleyson',
lastText: 'Berlin',
face: 'img/adam.jpg'
}, {
id: 3,
name: 'Perry Governor',
lastText: 'Tokio',
face: 'img/perry.png'
}, {
id: 4,
name: 'Mike Harrington',
lastText: 'Milan',
face: 'img/mike.png'
}];
As you see every list item has a lastText with a name of city. And this is my view file: `
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-init="getWeather(chat.lastText)" ng-repeat="chat in chats" type="item-text-wrap" href="#/tab/chats/{{chat.id}}" >
<img ng-src="{{chat.face}}">
<h2>{{cityname}}</h2>
<p>{{dweather}}</p>
<i class="icon ion-chevron-right icon-accessory"></i>
<ion-option-button class="button-assertive" ng-click="remove(chat)">
Delete
</ion-option-button>
</ion-item>
</ion-list>
`
I have a function getWeather(chat.lastText)
which returns weather of selected city. Variables cityname
and dweather
. I want to show weather of every city stored in lastText variable of every list item. But it shows only weather of first city for every list item. My question is how to make it possible?