0

i just working with Wikitude and Google maps in AngularJS(Ionic). I need to set ng-click event for InfoWindow in my controller. My code:

google.maps.event.addListenerOnce($scope.map, 'idle', function(){

  var marker = new google.maps.Marker({
      map: $scope.map,
      animation: google.maps.Animation.DROP,
      position: latLng
  });

  var infoWindow = new google.maps.InfoWindow({
      content: '<a href="#" ng-click="launchAR(\'my_world_pls\')">CATCH!</a>'
  });

  google.maps.event.addListener(marker, 'click', function () {
      infoWindow.open($scope.map, marker);
  });

});

2 Answers2

0

You cannot link dynamically created HTML directly to controller. There are two options mentioned in this link

Other option is to use jQuery. For this you can give an id to the anchor elementand find the element by ID and attach click event.

Community
  • 1
  • 1
Arun Ghosh
  • 7,634
  • 1
  • 26
  • 38
0

Solved.

google.maps.event.addListenerOnce($scope.map, 'idle', function() {

    var marker = new google.maps.Marker({
      map: $scope.map,
      animation: google.maps.Animation.DROP,
      position: latLng
    });

    google.maps.event.addListener(marker, 'click', function() {
      $scope.launchAR('mana_catch_and_eat');
    });

  });