最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Passing Meteor's Iron Router Parameters to Template Callback - Stack Overflow

programmeradmin3浏览0评论

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

}

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

}
Share Improve this question asked Apr 15, 2014 at 20:24 NyxynyxNyxynyx 63.6k163 gold badges505 silver badges855 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 25

Have you tried Router.current().params?

发布评论

评论列表(0)

  1. 暂无评论