更新:这里有这种情况的文档: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