I am using a leaflet Directive to show maps on openStreet map.To list all markers my code looks like this :
$scope.goTo = function() {
restAPI.getSomething().success(function(data) {
var anArray = data.lists;
console.log(anArray);
var anotherList = {};
angular.forEach(anArray, function(value, key) {
if (value.geolocation) {
$scope.project = value;
anotherList[anArray[key].ao] = {
lat: value.lat,
lng: value.lng,
focus: false,
draggable: false,
icon: icon,
message: '<button type="button" ng-click="openProject(project)">' + value.ao + '</button> {{project.ao}}',
clickable: true
}
}
});
$scope.map.anotherList = anotherList;
});
}
Here in that message template i am adding a button with a function call, As i understood to pass a variable in template, Scope is the solution, but here, on all markers value.ao name is different but project.ao is same ...(why ????)
when i click on each marker its opening last project in array(anArray).
How can i bind scope value in each iteration ?,So i can open correct project on each marker