有没有办法在infowindow内容中创建ng-click angularjs指令?
var infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: '<div ng-click="???" class="infowindow"></div>'
});
答案 0 :(得分:21)
您需要首先使用类似
的内容编译HTML元素var htmlElement = '<div ng-click="???" class="infowindow"></div>'
var compiled = $compile(htmlElement)($scope)
然后将InfoWindow Content设置为
var infowindow = new google.maps.InfoWindow({
map: map,
position: pos,
content: compiled[0]
});