12

有没有办法在信息窗口内容中创建一个 ng-click angularjs 指令?

var infowindow = new google.maps.InfoWindow({
                    map: map,
                    position: pos,
                    content: '<div ng-click="???" class="infowindow"></div>'
                  }); 
4

1 回答 1

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]
              }); 
于 2013-11-14T00:57:08.347 回答