map.component.ts代码:
......
infoWindow = new google.maps.InfoWindow(
{
content: `<custom-tag></custom-tag>` //***not displaying anything***
});
infoWindow.open(map, marker);
......map.component.html代码:
<custom-tag></custom-tag> <!--***displays hi***-->
<div class="google-maps"></div>定制标记.Component.html代码:
<h2>hi</h2>module.ts、routing.ts文件肯定没有错误。信息窗口只是打开和显示什么,请帮助我找出为什么信息没有显示任何东西。
发布于 2017-04-17 09:37:48
您必须通过ComponentFactoryResolver动态创建组件。
const compFactory = this.resolver.resolveComponentFactory(CustomTag);
this.compRef = compFactory.create(this.injector);
this.appRef.attachView(this.compRef.hostView);
let div = document.createElement('div');
div.appendChild(this.compRef.location.nativeElement);
this.infoWindow.setContent(div);
this.infoWindow.open(this.map, marker);这是柱塞实例
不要忘记将CustomTag组件添加到entryComponents中
https://stackoverflow.com/questions/43448577
复制相似问题