我的_id值来自铁路由器。
我的代码:
Template.template_name.helpers({
'edit': function () {
var id = Router.current().params._id;
return Collection.find.One({ _id: id});
}
});
上述代码不起作用。
答案 0 :(得分:0)
首先检查ID是否正确返回,不带警报或控制台。
Template.template_name.helpers({
'edit': function () {
var id = Router.current().params._id;
alert(id);
return Collection.find({ _id: id});
}
});
在路由器中你必须像这样传递:
Router.route('/template/:_id', {
name: 'template',
template: 'template',
});