假设我们有一个父模板和一个子模板:
<template name="parent">
{{> child }}
</template>
<template name="child">
{{#if show}}
//Do something
{{/if}}
</template>
如果我们将'show‘赋值给父模板:
if (Meteor.isClient){
Template.parent.show = function(){
return Session.get('isShowing');
}
}
有没有办法让子模板访问它?
发布于 2015-06-04 19:46:56
您还可以注册一个通用帮助器:
Template.registerHelper('isTrue', function(boolean) {
return boolean == "true";
});
在你的html中这样命名:
<input type="checkbox" checked="{{isTrue attr}}"/>
https://stackoverflow.com/questions/15127121
复制相似问题