我想做的是:
例如:
简单的设置,我的HTML是:
<template name = "cities">
{{#each city}}
<p>{{cityname}}></p>
{{/each}}
</template>和联合来文:
Template.cities.helpers({
'city': function(){
var country = Session.get('currentCountry');
return Cities.find({ country: country}, {sort: {population: -1}});
}
});这一切都很好,但我想在城市旁边显示一个数字(这个数字是它们在DOM上加载的顺序,这将取决于从Mongo检索城市列表的方式)。
然后,我需要以某种方式将这个数字传递给Google标记创建功能。
任何帮助都是非常感谢的!
发布于 2016-05-19 03:16:19
事实证明,这是微不足道的(谢谢米歇尔)
新HTML:
<template name = "cities">
{{#each city}}
<p>{{@index}} {{cityname}}></p>
{{/each}}
</template>如果要将索引增加1(或任何其他值),请参见以下内容:Adding offset to {{@index}} when looping through items in Handlebars
https://stackoverflow.com/questions/37306633
复制相似问题