I am working on a user profile page and I am trying to pass data from the controller to a template helper. Here's my controller:
usersDetailController = RouteController.extend({
waitOn: function () {
Meteor.subscribe('userProfileExtended', this.params._id);
},
data: function(){
console.log('info is ' + this.params._id);
var a = Meteor.users.findOne(this.params._id);
console.log(a);
return Meteor.users.findOne(this.params._id);
},
action: function() {
this.render('Users');
}
});
Here's my template helper:
Template.Users.helpers({
user: function() {
//define user based on the data context from the route controller
}
});
Can someone offer me some guidance on how to pass data that I defined in the controller in the template helper??
Thanks!!
Get rid of the helper and use this pattern instead :
data: function(){
return {
user: Meteor.users.findOne(this.params._id)
};
}
This way you'll be able to reference user
in your template because the data context will be set to the result of the route data function.