Nyxynyx
Nyxynyx

Reputation: 63599

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

}

Upvotes: 10

Views: 3300

Answers (1)

nickytonline
nickytonline

Reputation: 6981

Have you tried Router.current().params?

Upvotes: 25

Related Questions