meteor - How to access the subscriptions inside the HTML file? -
usually when use helpers, can access returned values below:
template.oveview.helpers({ item: function () { return requests.find({}); }, then in client side can use {{#each item}}, don't know how display them in .html when using publish , subscribe
here publish:
meteor.startup(() => { meteor.publish('requests', function queryrequests() { return requests.find({}); }); }); and here subscribe:
template.overview.oncreated(function() { meteor.subscibe('requests'); }); how can display returned value publish in client side?
you can use in few different ways. can use meteor templates insert html snippet every item in-between existing html:
{{#each item}} {{> htmltemplatename}} {{/each}} or can place raw html in {{#each}} loop:
{{#each item}} <p>{{propertyx}}</p> <p>{{propertyy}}</p> {{/each}} you might run problems pubsub, depending on load order (i don't know load orders, i'm afraid). used iron-router package in project, bind end-points specific html files. iron-router has nice parameter can set every page, called waiton, placed subscriptions. means subscribing collection happens before else.
router.configure({ layouttemplate: '_layouttemplate', name: 'mytemplatename', waiton: function() { return [ meteor.subscribe('requests'), //add other subscriptions here ]; } });
Comments
Post a Comment