Pass data from router to template helper


#1

How can data from Router.route be passed onto a template helper. So I want to use a user _id from my iron router to be used in my template helper to get documents for that particular user. This is the code:

    Router.map(function() {
        this.route('/user/:_id', {
        template: 'userPage',
        data: function(){
            var currentList = this.params._id;
            return Meteor.users.findOne({ _id: currentList });
         }
      });
    });

So how can the currentUser in the templates.js file be assigned with the value of currentList from the routes.js file?

    Template.userPage.helpers({
        name: function () {
            var currentUser = this.currentList; 
            console.log(currentUser);
            var user = Meteor.users.findOne({ _id: currentUser });
            return user.usernamex;
        }
    });

Currently it returns undefined

Thanks


#2

Solution can be found at http://stackoverflow.com/questions/31528955/pass-parameters-from-router-to-templates-helper-on-meteor

So use Router.current().params._id