将Meteor的铁路由器参数传递给模板回调

时间:2014-04-15 20:24:59

标签: javascript node.js meteor

如何将Iron Router参数传递给Template.myTemplate.rendered回调?以下路由和回调函数为undefined提供了console.log

网址

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

}

1 个答案:

答案 0 :(得分:25)

你试过Router.current()。params?