Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Meteor's Iron Router Parameters to Template Callback

How do you pass the Iron Router parameters to a Template.myTemplate.rendered callback? The following route and callback function gives undefined for both console.log.

URL

http://localhost:3000/story/1234

Router.js

Router.map( function() {

    this.route('story', {
        path: '/story/:_id',
        template: 'story'
    })

})

story.js

Template.story.rendered = function () {

    console.log('params: ', this.params)    // undefined
    console.log('_id: ', this._id)    // undefined

}
like image 368
Nyxynyx Avatar asked Apr 15 '14 20:04

Nyxynyx


1 Answers

Have you tried Router.current().params?

like image 90
nickytonline Avatar answered Sep 18 '22 12:09

nickytonline