Search code examples
mongodbmeteorflow-router

how to pass data between templates meteor js


i'm working with Meteor js and i'm trying to pass data from a template to another and this is my code :

BuildingsAction.js

  Template.BuildingsAction.viewmodel({
     showExhibitions() {

        FlowRouter.go("/exhibitions");

    },})

Actually i would like to pass an _id from BuildingsAction to exhibitions

   Template.exhibitions.viewmodel({
    onCreated: function () {
        this.idItemParent(BuildingsAction_id)// here i whoud like to get the id 
        })}

Solution

  • There are two ways.

    1. Using session.

    `Session.set('idVar',YourId);`
    

    Get Session Value: Session.get('idVar');

    2. You can send the id in URL

    FlowRouter.go("/exhibitions",{},{id:YourID});

    Get queryparam Value: FlowRouter.getQueryParam("id");