2

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">

2 Answers 2

1

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';
}
Sign up to request clarification or add additional context in comments.

12 Comments

It said 'SyntaxError: Left hand side of operator '=' must be a reference.'
soon, it said null is not an object .
which map module are you using? Provide link to the docs. Also a live plunker demo would help
ngmap.github.io/#/!custom-marker-two-way-binding.html, I am running this one but want to click that button to innerHTML a div
as you know, button1 demonstrates div1 and so on, thank you again to take a look of my trouble.
|
0
<div ng-repeat="i in [] | range:100">
//do stuff
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.