Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-click inside a infowindow content of google maps

Is there a way to create an ng-click angularjs directive inside an infowindow content?

var infowindow = new google.maps.InfoWindow({
                    map: map,
                    position: pos,
                    content: '<div ng-click="???" class="infowindow"></div>'
                  }); 
like image 225
gamosa Avatar asked Nov 14 '13 00:11

gamosa


1 Answers

You will need to compile the HTML element first with something like

var htmlElement = '<div ng-click="???" class="infowindow"></div>'
var compiled = $compile(htmlElement)($scope)

then set InfoWindow Content to be something like

var infowindow = new google.maps.InfoWindow({
                map: map,
                position: pos,
                content: compiled[0]
              }); 
like image 122
kebomix Avatar answered Sep 20 '22 09:09

kebomix