So I have this DATA context that I'm gripping and cant figure out how to pass it to the template. Could anyone show or direct me to an example? Do I need a template helper where I will go once more into the DB to retrieve the data, since I already have the data context in the iron router...?
ROUTER.js
Router.route("/employer", {
name:"employer",
template:"employer",
layoutTemplate:'employerLayout',
// controller:"ProfileController",
data: function(){
var currentuser = Meteor.userId();
Meteor.call("getEmployer", currentuser, function(error, result){
if(error){
console.log("error", error);
}
if(result){
return result;
}
});
},
EMPLYER.html
<template name="employer">
<h1> Employer</h1>
<h2>{{result}}</h2>
</template>
COLLECTION
meteor:PRIMARY> db.employer.find().pretty()
{
"_id" : "qCFGZa4ogc5LR56PL",
"createdAt" : ISODate("2015-07-18T13:19:16.098Z"),
"user" : "owfJ4ozrfsp26o8G4"
}
For example I would like to write out
<template name="employer">
<h1> Employer</h1>
<h2>{{_id}}</h2>
<h2>{{createdAt}}</h2>
<h2>{{user}}</h2>
</template>