meteor - Use ReactiveVar in {{each}} helper -
i have reactivevar in helper returns number of photos placed in template
photocount:-> template.instance().rvphotocount.get() now need reactively populate html # of img returned photocount. tried using {{each photocount}}<img> receive error {{#each}} accepts arrays, cursors or falsey values.
how tackle this?
the {{#each}} operator used iterating on list of things, such as, in case, list of images.
currently passing {{#each}} number of images have. , each not know how iterate on single number!
if want display each of images, should pass each image list itself, in form of array or cursor:
{{#each images}}<img src={{src}} />{{/each}} if want display number of images, use {{photocount}}!
<p>there {{photocount}} images.</p> if want print number of same "static" img, you'll have pre-process array in helper:
photocount: function(){ var countarr = []; var count = template.instance().rvphotocount.get(); (var i=0; i<count; i++){ countarr.push({}); } return countarr; } and use {{#each}} on it. sadly, meteor limited in terms of built-in templating functionalities.
Comments
Post a Comment