How do you send info from 2 different collections to one route in iron-router for meteor?
For example I have a Posts
and Comments
collection and wanted to assign both Posts.findOne(this.params._id)
and Comments.find({postId: this.params._id})
to the data
field of route detailedPost
route so that I could display both the post details and the comments for that post.
You can easily assign them to parameters of the data
object:
Router.map(function() {
this.route('detailedPost', {
path: '/post/:id',
data: function() {
return {
post: Posts.findOne(this.params._id),
comments: Comments.find({postId: this.params._id}),
};
},
});
});