-
StackOverflow 文件
-
meteor 教程
-
Blaze Templating
-
從方法呼叫填充模板
<template name="myTemplate">
{{#each results}}
<div><span>{{name}}</span><span>{{age}}</span></div>
{{/each}}
</template>
Template.myTemplate.onCreated(function() {
this.results = new ReactiveVar();
Meteor.call('myMethod', (error, result) => {
if (error) {
// do something with the error
} else {
// results is an array of {name, age} objects
this.results.set(result);
}
});
});
Template.myTemplate.helpers({
results() {
return Template.instance().results.get();
}
});