Pavan K
Pavan K

Reputation: 4693

meteor not printing any data

I have the following application and when I render data I am getting null or no data for the {{video}} tag even though data exists in the collection Can anyone help me find the mistake

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

Upvotes: 0

Views: 29

Answers (1)

David Weldon
David Weldon

Reputation: 64312

find returns a cursor. That would work if you were iterating over a set of videos with #each. In your case you want a specific video so you'd need to use findOne like this:

Router.route('/videos/:_id', function () {
  this.render('VideoItem', {
    data: function () {
      return Videos.findOne(this.params._id);
    }
  });
});

Upvotes: 1

Related Questions