Iron Router Multiple Data Context with Meteor

How toIron RouterMeteor

Here’s how to do it:

Router.route('/things', {

    name: 'things',    

    waitOn: function () {

        return [this.subscribe('thing'),this.subscribe('thinga')];

    },

    data: function () {

        return {

            thing: Thing.find(),

            thinga: Thinga.findOne({type: "abc"})

        };

    },

    onAfterAction: function () {

        Meta.setTitle('Things');

    }

});

To access the data context in the Template use the following syntax:

console.log('Template.instance().data.thinga.propertyname', Template.instance().data.thinga.propertyname);

 

References:

https://iron-meteor.github.io/iron-router/