Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将编译好的角度模板传递给HereMaps API_Javascript_Html_Angular_Compilation - Fatal编程技术网

Javascript 将编译好的角度模板传递给HereMaps API

Javascript 将编译好的角度模板传递给HereMaps API,javascript,html,angular,compilation,Javascript,Html,Angular,Compilation,我在我的Angular应用程序中使用HereMaps,目前为止运行良好。我当前的问题是,H.ui.InfoBubble组件只接受普通html,不接受角度模板 let bubble = new H.ui.InfoBubble( { lat: data.ride.position.latitude, lng: data.ride.position.longitude }, // this is currently unfortunately not working, the

我在我的Angular应用程序中使用HereMaps,目前为止运行良好。我当前的问题是,H.ui.InfoBubble组件只接受普通html,不接受角度模板

 let bubble = new H.ui.InfoBubble(
      { lat: data.ride.position.latitude, lng: data.ride.position.longitude },
      // this is currently unfortunately not working, the content gets copied 1:1
      { content: '<app-my-angular-component></app-my-angular-component>'}
let bubble=new H.ui.InfoBubble(
{lat:data.ride.position.latitude,lng:data.ride.position.longitude},
//不幸的是,这目前不起作用,内容以1:1的比例复制
{内容:''}
我想在有生之年编译模板,但在这里没有成功


感谢您的帮助!

您可以传递DOM树节点,而不是通过HTML传递字符串。因此,您可以获取和组件
nativeElement
并将其传递给函数。然后,您可以将其从DOM树中移除,最后将其传递给气泡


我在这方面没有什么经验,因此无法提供示例

谢谢@kvetis的提示

这些是取得成果的必要步骤:

// 1. Add your bubble component to entryComponents
...
entryComponents: [BubbleComponent]
...

// 2. Add these includes
import { Component, OnInit, ViewChild, ElementRef, ViewContainerRef,    
    ComponentFactoryResolver } from '@angular/core';

// 3. Init your Viewchild
@ViewChild("map", { static:false, read: ViewContainerRef }) mapContainer: 
    ViewContainerRef

// 4. Create the "factory" on your bubbleComponent in ngOnInit
this.factory = this.resolver.resolveComponentFactory(BubbleComponent);

// 5. Create your component dynamically and it to your Dommarker
let componentRef = this.mapContainer.createComponent(this.factory);
let bubble = new H.ui.InfoBubble(
{ lat: data.ride.position.latitude, lng: data.ride.position.longitude },
   // The FO property holds the province name.
   {
      content: componentRef.location.nativeElement
});

// 6. Don't forget to destroy your component refs on destroy
可以找到更多信息