第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Angular2-組件到動態(tài)創(chuàng)建的元素中

Angular2-組件到動態(tài)創(chuàng)建的元素中

心有法竹 2019-11-20 09:57:33
我使用Google Maps JavaScript API,并且必須在InfoWindow中顯示一個Angular組件。在我的項目中,我使用該Jsonp服務(wù)加載了Google Map API 。比我有g(shù)oogle.maps.Map可用的對象。稍后,在組件中,我創(chuàng)建了一些標(biāo)記并將單擊偵聽器附加到它們:打字稿:let marker = new google.maps.Marker(opts);marker.setValues({placeId: item[0]});marker.addListener('click', (ev: google.maps.MouseEvent) => this.onMarkerClick(marker, ev));然后在click處理程序中,我想打開一個包含Angular組件的信息窗口:打字稿:private onMarkerClick(marker: google.maps.Marker, ev: google.maps.MouseEvent) {    var div = document.createElement();    this.placeInfoWindow.setContent(div);    // Magic should happen here somehow    // this.placeInfoWindow.setContent('<app-info-view-element></app-info-view-element>');    this.placeInfoWindow.open(this.map, marker);}我最后要做的是一些普通的JS:打字稿: private onMarkerClick(marker: google.maps.Marker, ev: google.maps.MouseEvent) {    let div = document.createElement('div');    div.className = 'map-info-window-container';    div.style.height = '140px';    div.style.width = '240px';    this.placeInfoWindow.setContent(div);    this.placeInfoWindow.open(this.map, marker);    this.placesService.getPlace(marker.get('id')).subscribe(res => {      this.decorateInfoWindow(div, res.name, marker);    }, error => {      this.decorateInfoWindow(div, ':( Failed to load details: ', marker);    });  }據(jù)我了解,問題是創(chuàng)建動態(tài)組件的唯一可行方法是使用Angulars ViewContainerRef:如何在容器中放置動態(tài)組件但是沒有文檔或示例,沒有描述如何ViewContainerRef從動態(tài)創(chuàng)建的元素創(chuàng)建。強制框架以某種方式處理DOM是否可行?由于它在許多線程中都被聲明為:“ Angular不處理innerHTML或appendChild”。這是一個完全的死胡同嗎?第二:是否可以使用Renderer實現(xiàn)?(不熟悉),我看過這個Canvas Renderer實驗,從理論上講,我猜想它也可以在Google地圖上使用,因為我們可以推斷出該地圖只是一種特殊的畫布。它在最新版本中仍然可用還是已更改?DomRenderer不在文檔中,但是可以在源代碼中找到它。
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 941 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號