[英]google maps infoWindow button ( ionic ) issue
Im traryng to do something like this on ionic 我打算在离子上做这样的事情
But i have a issue when i add a infoWindows button , specifically in this section (click)="ir()"
(angular) 但是,当我添加一个infoWindows按钮时,特别是在此部分中,我遇到了一个问题(click)="ir()"
(角)
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); }); }
Sorry for my english 对不起我的英语不好
when i click on it nothing happens. 当我单击它没有任何反应。 then i changed (click)="ir()"
for onclick="ir()"
and it throw me the next error 然后我将onclick="ir()"
更改为(click)="ir()"
onclick="ir()"
,这将引发下一个错误
(index):1 Uncaught ReferenceError: ir is not defined at HTMLButtonElement.onclick ((index):1) (索引):1未捕获的ReferenceError:在HTMLButtonElement.onclick中未定义ir((索引):1)
try 尝试
marker.addListener('click',()=>{
infoWindow.setContent('<h1> '+ title +'</h1>' +
'<button class="mapaboton" (click)="ir()">Ver Detalles</button>');
infoWindow.open(map,this);
});
You can use NgZone for 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>" });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.