代码片段客户端:
Template.projectEditButton.events({
"click .edit": function() {
Router.go('projectForm', {prjId: this._id});
}
});
此时,this._id是正确的。在路由器文件中:
Router.route('/projects/form', {
name: 'projectForm',
data: function() {
return Projects.findOne(this.params.prjId);
}
});
this.params是空的。我错过了什么?
答案 0 :(得分:4)
您需要将参数添加到路径定义中,以使映射起作用:
Router.route('/projects/form/:prjId', {
name: 'projectForm',
data: function() {
return Projects.findOne(this.params.prjId);
}
});