【发布时间】:2015-11-09 13:18:29
【问题描述】:
我是 Meteor 框架的新手,我正在尝试使用流星 + mongo + 空格键显示一些数据。问题是我可能需要对空格键使用一个参数#each,但它不允许这样做。
我的代码:
$ 文件.js
Template.home.helpers({
places: function() {
return Places.find();
}
});
Template.content.helpers({
images: function() {
return Images.find({});
}
});
$ 文件.html
<template name="home">
{{#each places}}
{{>content}}
{{/each}}
</template>
<template name="content">
<li>{{name}} - {{date}}</li>
{{#each images}}
<img src="{{this.url}}">
{{/each}}
</template>
我想要做的——但它没有用——是在 Template.content.helper 函数中使用一个参数,如下所示:
Template.content.helpers({
images: function(ARG) {
return Images.find({place: ARG});
}
});
在 html 文件中会是
<template name="content">
<li>{{name}} - {{date}}</li>
{{#each images {{name}} }}
<img src="{{this.url}}">
{{/each}}
</template>
你们知道如何正确显示信息吗?我不想显示每个地方的所有信息(图像)。我只想显示那个地方的图片通讯员...
提前致谢, 马库斯
【问题讨论】:
-
你能在接收参数的助手中做一个
console.log(Array.prototype.slice.call(arguments))吗?
标签: mongodb meteor meteor-blaze spacebars