How to use helper functions in Meteor for render data
Posted By : Parveen Kumar Yadav | 14-Jul-2016
In meteor to render data you need to use helper functions.
So for defining helper just go to your template js file for example if you have a template name as allInventory so just go to allInventory.js file and write the helper as follows:-
Template.allInventory.helpers({ })
make a function inside this helper on which you put your logic for getting data from Database or Session or from other service and than use that in you html like:-
Template.allInventory.helpers({ productDetails: function() { return Session.get('dbData'); } })
On html side you just need to use the function name as follows:-
{{#each productInfo in productDetails}}{{/each}} {{productInfo.item_name}} {{productInfo.seller_sku}} {{productInfo.quantity}} {{productInfo.price}}
As you can see in above productDetails a function name in your helper class on which you get the data you want to render on your Html is accessible directly via that name and you can traverse that via each loop in html templates.
In this way you can render the data on html via use of helpers in Meteor.
Thanks
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Parveen Kumar Yadav
Parveen is an experienced Java Developer working on Java, J2EE, Spring, Hibernate, Grails ,Node.js,Meteor,Blaze, Neo4j, MongoDB, Wowza Streaming Server,FFMPEG,Video transcoding,Amazon web services, AngularJs, javascript. He likes to learn new technologies