2014-03-12 28 views

回答

2

您可以轻松地将它们分配给data对象的参数:

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}), 
     }; 
    }, 
    }); 
}); 
+0

感谢,并为他人与您使用访问它们在你的模板同样的问题记{{#with后}} {{/带}}或{{#each comment}} {{/ each}} – whataboutki

+0

或者只是'{{post.title}}','{{post.body}}'等等 –

+0

谢谢Hubert。我不知道这一点,它有很大的帮助。我在Meteor上找到的所有文档都有路由器端的示例,但不知道如何访问模板端的东西,因此需要某处。 – whataboutki

相关问题