我有以下应用程序,当我渲染数据时,即使集合中存在数据,我也无法获得 {{video}}
标签的数据或没有数据任何人都可以帮我找到错误
routes.js
Router.route('/videos/:id', function () {
var item = Videos.find({_id: this.params._id});
this.render('VideoItem', { data:item});
});
video.html
<template name="VideoItem">
<div class="container">
<h3> Video Information</h3>
{{video}}
</div>
</template>
video object when Videos.find().fetch()
_id: "FEXm65hwZ9QWXFSY8"
created_at: Mon May 18 2015 14:22:59 GMT+0200 (CEST)
duration: 10000
video: "temp"
videourl: "http://google.com"
__proto__: Object
最佳答案
find
返回一个光标。如果您使用 #each
迭代一组视频,那么这会起作用。在您的情况下,您需要特定的视频,因此您需要使用 findOne
,如下所示:
Router.route('/videos/:_id', function () {
this.render('VideoItem', {
data: function () {
return Videos.findOne(this.params._id);
}
});
});
关于javascript - meteor 不打印任何数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30337359/