[英]Display template if collection is null or not in MeteorJS
我不确定在meteorjs中是否可行,我有两个模板“注册”和“登录”。 我想提出一个条件:
如果收集为空,则显示注册模板
如果不是,则显示登录模板。
请指教 。 。 非常感谢。
您可以使用助手功能。
HTML:
<template name="main">
{{#if collectionHasItems}}
{{> login}}
{{else}}
{{> register}}
{{/if}}
</template>
<template name="register">
// More code here
</template>
<template name="login">
// More code here
</template>
JS:
Template.main.helpers({
collectionHasItems: function() {
return Collection.find().count();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.