google 地图信息窗口按钮(离子)问题

google maps infoWindow button ( ionic ) issue

我想在 ionic 上做这样的事情

DEMO

但是我在添加 infoWindows 按钮时遇到了问题, 具体在本节 (click)="ir()" (angular)

 ir(){
    console.log("go");
  }

      addMarker(position,map,title){
        var marker = new google.maps.Marker({
          position,
          map,
          title
        });

        var infoWindow = new google.maps.InfoWindow({
          content:" "
        });
        


        marker.addListener('click',function(){
          infoWindow.setContent('<h1> '+ title +'</h1>' +
              '<button class="mapaboton" (click)="ir()">Ver Detalles</button>'); 
            infoWindow.open(map,this);
        });



      }

对不起我的英语

当我点击它时没有任何反应。 然后我将 (click)="ir()" 更改为 onclick="ir()",它抛出下一个错误

(index):1 Uncaught ReferenceError: ir is not defined at HTMLButtonElement.onclick ((index):1)

尝试

marker.addListener('click',()=>{
          infoWindow.setContent('<h1> '+ title +'</h1>' +
              '<button class="mapaboton" (click)="ir()">Ver Detalles</button>'); 
            infoWindow.open(map,this);
        });

您可以为此使用 NgZone:

import { NgZone } from '@angular/core';

constructor(public ngZone: NgZone) {}

(<any>window).ionicPageRef = {
    zone: this.ngZone,
    component: this
};

let infoWindow = new google.maps.InfoWindow({
    content: <button onClick='window.ionicPageRef.zone.run(function () { window.ionicPageRef.component.MyFunction() })'>My button</button>"
});