Meteor Router.go不通过params

时间:2015-04-14 19:10:46

标签: javascript meteor iron-router

代码片段客户端:

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是空的。我错过了什么?

1 个答案:

答案 0 :(得分:4)

您需要将参数添加到路径定义中,以使映射起作用:

Router.route('/projects/form/:prjId', {
  name: 'projectForm',
  data: function() {
    return Projects.findOne(this.params.prjId);
  }
});