Reputation: 24218
I know that I can put :id in the path of my route so that I get a specific URL. Thats what I can get form tutorials I found online. But how can I make use of this feature? What is the benefit? I assume that the ID is passed internally as like an url parameter, since in the data function seems to be specific return, based on an ID. But I am not sure.
this.route('projectView',{
path:'/projects/:id',
layoutTemplate:'mainLayout',
loginRequired:'entrySignIn',
waitOn:function(){
Meteor.subscribe('customers');
return Meteor.subscribe('projects');
},
data:function(){
Session.set('active_project',this.params.id);
return Projects.findOne({_id:this.params.id});
},
Upvotes: 0
Views: 152
Reputation: 64312
In your example, the path
looks like /projects/:id
. Under the hood, the router converts the contents of :id
into this.params.id
which is what you are using in your data
hook.
In other words, if the path /projects/abc123
was encountered by the router, it would know that it should use the projectView
route and this.params.id
should equal abc123
when loading the corresponding data.
Upvotes: 1