meteor - MeteorJs: Return data Iron:router -


iron router return data in template can't use it.

for example have db jobs, every job has position (e.g. jobs.position):

existjobpostcontroller = routecontroller.extend({   layouttemplate: 'existjob',   data:function() {return posts.findone(this.params._id); } }) router.map(function() {   this.route('existjob', {         path: '/jobs/:_id',     controller: existjobpostcontroller,   }); }); <template name="existjob">         {{position}} </template> 

and nothing happens, think it's fault, can't understand how fix this.

can help?

you should first check correct data being set on template data context. here's quick general summary of how set data context , how access various locations:

router.map(function() {   this.route('index', {         path: '/index',     data: function(){       var obj = {         fname: "tom",         lname: "smith"       };       return obj;     }   }); });  template.index.onrendered(function(){   console.log(this.data.fname); });  template.index.events({   'click body': function(e, tmpl){     console.log(tmpl.data.fname);   } });  template.index.helpers({   lastname: function(){     return this.lname;   } });  <template name="index">    have use `this` when directly accessing template data spacebars.   {{this.firstname}}    following comes template.index.helpers:   {{lastname}}  </template> 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -