【发布时间】:2015-11-04 18:40:12
【问题描述】:
我是meteor.js 的新手,我正在练习构建一个简单的小应用程序。我的问题是如何在模板里面使用从mongodb获取的模板数据。这是结构:
路由器.js
Router.route('/point/:_id', {name: 'pointDetail', data: function() {
return InterPoints.findOne(this.params._id);
} });
模板pointDetail.html
<template name="pointDetail">
<some tags>
{{datathree}}
</some tags>
{{> map}}
</template>
模板图.html
<template name="map">
<div class="map-container">
{{> googleMap name="exampleMap" options=exampleMapOptions}}
</div>
</template>
map.js
Template.map.helpers({
exampleMapOptions: function() {
// Make sure the maps API has loaded
if (GoogleMaps.loaded()) {
// Map initialization options
return {
center: new google.maps.LatLng(coordX, coordY),
zoom: 8
};
}
}
});
我想使用从路由器检索到的数据在 map.js 中填充 coorsx 和 coordy。 像 coordx = {{coordsx}} 有可能吗?
非常感谢。
【问题讨论】:
-
我想你可以简单地在那里申请collections。如果没有,请查看session variables。
标签: meteor