角度:编译谷歌地图信息窗口内容以使用ng-click

Angular: compile google maps infoWindow content to use ng-click

本文关键字:ng-click 窗口 编译 谷歌地图 信息 信息窗 角度      更新时间:2023-09-26

我正在尝试将ng-click处理程序添加到我的infoWindow中的某些动态html中,如下所示,这对于常规角度指令工作正常,但不适用于infoWindow:

      google.maps.event.addListener(marker, 'click', function() {
          console.log('will compile',marker.cinemaInfo);
          var html = $compile(marker.cinemaInfo)(scope); 
          infowindow.setContent(html);
        }
        infowindow.open(scope.map,marker);
        scope.$apply();
      });

,虽然有一些帖子说人们需要 outerHTML,但就我而言,我有以下版本在工作:

var html = $compile(marker.cinemaInfo)(scope); 
infowindow.setContent(html[0]);

而不是:

var html = $compile(marker.cinemaInfo)(scope); 
infowindow.setContent(html[0].outerHTML);