Meteor, Iron:Router Passing Multiple Properties on Router.go

和自甴很熟 提交于 2019-12-03 00:07:10

Is the question how to pass multiple parameters to Router.go? Just put all of them in the object for the second parameter:

Router.go('itemDetails', {_id: 'foo', '_itemId': bar});

Edit:

Ok, if you want to pass arbitrary values to the url, you can use query paramters:

Router.go('itemDetails', {itemName: 'foo'}, {query: 'id=bar'});

The id will still be in the url though, it will look like this:

http://example.com/items/foo?id=bar

And you can retrieve it like this:

Router.route('/items/:itemName', {
    name: 'itemDetails',
    data: function(){
        return {
            item: Items.findOne(this.params.query.id),
            itemName: this.params.itemName
        };
    }
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!