有什么方法可以直接在 GMap infoWindow 對話框中顯示組件?
我想通過組件直接更改此 html 代碼(作為字串)
uj5u.com熱心網友回復:
是的,您可以使用 ViewChild 獲得指向該組件的參考,例如
@ViewChild(ExampleComponent, { read: ElementRef }) exampleComponent: any;
然后你可以使用 nativeElement.innerHTML 訪問它的 HTML 并在 infoWindow.setContent 函式中使用它
handleOverlayClick(event: any) {
this.infoWindow.setContent(this.exampleComponent.nativeElement.innerHTML);
this.infoWindow.open(event.map, event.overlay);
event.map.setCenter(event.overlay.getPosition());
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/403619.html
標籤:
