【发布时间】:2016-09-27 08:28:43
【问题描述】:
我想知道你能否给我一些线索来解决这个“问题”。我是 JS(+ Meteor)的新手,所以对你来说可能超级简单。我正在使用 helpers 和 blaze/spacebars 进行渲染。
我有一个简单的助手:
Template.monitoring.helpers({
'realtime': function(){
return {
house: house.find( {} ),
neighbours: neighbours.find( {} ),
}
} // end of realtime
}); // end of helpers
此时,一切正常。我能够检索我想要的数据。问题是我无法像我想要的那样渲染它。下面是我的template。
<template name="monitoring">
{{#each realtime.house}}
<div class="card red">
SHOW STUFF ABOUT HOUSE
</div>
<div class="card blue">
{{#each realtime.neighbours}}
SHOW STUFF ABOUT NEIGHBOURS OF THE SPECIFIC HOUSE
{{/each}}
</div>
{{/each}} -> end of each realtime.house
</template>
更准确地说,当我的模板被渲染时:
- 红牌数 = 房子数 => 完美
每张红牌都包含一个房子的数据=>完美
蓝牌数 = 房子数 => 完美
- 每张蓝卡都包含所有邻居的数据 => 错误。我想要的是关于特定房子的邻居的数据
您知道如何在正确的地方获得正确的东西吗? 非常感谢。
【问题讨论】:
标签: templates meteor meteor-blaze helpers