【问题标题】:Pass parameters from Router to Template's helper on Meteor将参数从路由器传递到 Meteor 上的模板助手
【发布时间】:2015-07-21 12:00:42
【问题描述】:

我有一个路由器定义如下

Router.route('/profile/:input',function(){
    this.render('profile');
});

所以我可以通过调用this.params.input 来获取input 的值。我想在 MongoDB 上查询这个值并传递给模板 Profile。但是我怎样才能将这些信息从路由器交换到助手?

if (Meteor.isClient) {
    Template.profile.helpers({
        data: function(){
           //what to do?!
        }
    });
}

【问题讨论】:

    标签: node.js mongodb meteor iron-router


    【解决方案1】:

    在您的 Template.foo.helpers 中,您可以通过以下方式获取路由器参数:

    Router.current().params.input

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-02
      • 2015-07-10
      • 2015-08-25
      • 2015-09-30
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 2014-11-28
      相关资源
      最近更新 更多