如何將數組值加載到流星中的模板變量?請看下面的代碼,並建議我該怎麼做?如何將數組值加載到流星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];
};