Reputation: 268
I m new to iron router and want to pass one template'data to the calling template through Router.go() method. But i found it can be pass through query but i don't want to use query as my data is large JSON object. So, is there a way to pass data from one template to another template using iron-router. any help would be highly appreciated.
Upvotes: 0
Views: 101
Reputation: 1146
Use Session.set() before calling Router.go() and Session.get() on another template. This approach doesn't require round trip to database but be sure to not flooding Session object as it will persist throughout browser session.
Upvotes: 1
Reputation: 11187
Save it to some local collection then use the ID in the url is one way.
JSONCollection = new Mongo.Collection('some_json');
Template.yourTemplate.events({
'click button[data-action="go-to-next"]': function (e, template) {
var id = JSONCollection.insert(template.data);
Router.go('yourroute', { _id: id });
}
});
Then your url will just contain the id.
/yourroute/:someIdHere
Upvotes: 1