Created
November 29, 2012 07:33
-
-
Save kasima/4167392 to your computer and use it in GitHub Desktop.
Meteor.Router with and without session params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.Router.add({ | |
'/posts': 'posts', | |
'/posts/:id': function(id) { | |
Session.set('postId'); | |
return 'post'; | |
}, | |
'/authors/:id': function(id) { | |
Session.set('authorId', id); | |
return 'author'; | |
} | |
}); | |
Template.post.post = function () { | |
return Posts.findOne(Session.get('postId')); | |
}; | |
Template.author.author = function () { | |
return Authors.findOne(Session.get('authorId')); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.Router.add({ | |
'/posts': 'posts', | |
'/posts/:id': 'post', | |
'/authors/:id': 'author' | |
}); | |
Template.post.post = function () { | |
return Posts.findOne(Session.get('params').id); | |
}; | |
Template.author.author = function () { | |
return Authors.findOne(Session.get('params').id); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment