更新:這裏有這種情況的文檔:Conditional templates use the if attribute to conditionally create a template instance.Polymer,如何在渲染其他元素之前等待core-ajax完成?
這個程序,plnkr.co,應做到以下幾點:
- 使用核心AJAX組件從DB獲得project_location(JSON在這個例子中)
- 使用谷歌地圖組件來顯示帶有標記的地圖
- 當用戶拖動了市場,使用核 - AJAX來保存新的位置到DB
問:如何讓谷歌地圖組件等待渲染,直到AJAX請求完成?
目前出現此錯誤: 「在觀察者回調期間捕獲的異常:TypeError:緯度必須是數字」,我假設這是因爲google-map是在{{project_location}}啓動之前呈現的。
<core-ajax id="ajax_get_location"
auto
url="project_location.json"
params='{"idProject":"{{idProject}}"}'
on-core-response="{{locationLoaded}}"
handleAs="json"
response = "{{project_location}}"></core-ajax>
<google-map id="project_location_map"
zoom="{{project_location.location_map_zoom}}"
fitToMarkers>
<google-map-marker
latitude ="{{project_location.location_map_marker_latitude | toFixed(2)}}"
longitude ="{{project_location.location_map_marker_longitude | toFixed(2)}}"
title ="{{project_title}}"
draggable ="true"
>
{{project_title}}
</google-map-marker></google-map>
確定嗎?我試了一下,發現不管你使用if還是不影響結果。它出現在你得到迴應之後**。 – Melkor 2014-12-13 11:53:58