如何将数组值加载到流星中的模板变量?请看下面的代码,并建议我该怎么做?如何将数组值加载到流星JS中的模板变量?
HTML代码:
<template name="header">
<div class="header">
{{#each alphabets}}
<div class="alphabets">{{this}}</div>
{{/each}}
</div>
</template>
JS代码:
//the below array values are load dynamically above template
var Alphas = ['ALL',
'A', 'B', 'C', 'D','E', 'F',
'G', 'H', 'I', 'J','K', 'L',
'M', 'N', 'O', 'P','Q', 'R',
'S', 'T', 'U', 'V','W', 'X',
'Y', 'Z'
]
Template.header.alphabets = function (i)
{
return Alphas[i];
};