Reputation: 41
Two loops are existed here, the custom-maker works but the on-click function does not,the on-click changes all of 'mkrclick' which does not change mkrclick0 by clicking custom-maker0 and so on, do someone can teach me and solve the problem? I would thank to the guys very much.
<script>
angular.module('ngMap').run(function($rootScope) {
$rootScope.mouseover = function() {
console.log('mouseover', this);
this.style.backgroundColor = 'white';
};
$rootScope.mouseout = function() {
this.style.backgroundColor = '#FEF9E7';
};
$rootScope.click = function() {
for ( var e=0; e < map_data.length; e++) {
document.getElementById('mkrclick'+e).innerHTML = "<div>Paragraph changed!</div>";}};
$rootScope.customMarkers = [];
for (var i = 0; i < map_data.length; i++) {
$rootScope.customMarkers.push({
address: map_data[i].work_address,
"class": "my1",
content: map_data[i].work_address,
content_1: map_data[i].job_reward,
idnum: 'mkrclick'+ i
});
}
});
</script>
<custom-marker ng-repeat="cm in customMarkers" position=" {{cm.address}}"
on-mouseover="mouseover()" on-mouseout="mouseout()"
on-click="click()">
<div ng-repeat="cm in customMarkers" id='{{cm.idnum}}' class="padrep">
Upvotes: 2
Views: 76
Reputation: 143
<div ng-repeat="i in [] | range:100">
//do stuff
</div>
Upvotes: 0
Reputation: 171690
Pass cm
into the click()
function then use the properties of that marker object to do what is needed
on-click="click(cm)"
$rootScope.click = function(cm) {
document.getElementById(cm.idnum).innerHTML = 'TEST';
}
Upvotes: 1