gamosa
gamosa

Reputation: 291

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>'
                  }); 

Upvotes: 12

Views: 4473

Answers (1)

kebomix
kebomix

Reputation: 856

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]
              }); 

Upvotes: 21

Related Questions