如果集合在MeteorJS中为null或不为null,则显示模板
Display template if collection is null or not in MeteorJS
我不确定这在metrojs中是否可能,我有两个模板——"register"answers"login"。我想把一个条件放在哪里:
如果集合为空显示寄存器模板
如果没有,则显示登录模板。
请告知。非常感谢。
您可以使用助手函数。
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();
}
});
相关文章:
- php代码在textbox更改事件上显示null
- javascript对象显示为null,但object.properties返回数据
- 我的localStorage结果显示了[null,null,“something”]],而不是“”;什么”;
- 如何在网格视图中显示NULL值
- 为什么我的 webGL 上下文返回为 null,但也显示它已被检索
- 序列化的 JSON 对象在控制器处显示为 Null
- 某些 JSON 字段在命中 MVC 控制器方法时显示为 NULL
- app.js显示错误:TypeError:无法调用方法'查询'为null
- 如果字段为null,则在sitecore中显示none
- Dimplejs Bug.当序列不为null时,行不会显示
- 显示null的Javascript对象
- 如何正确使用熨斗可选?像铁页一样使用时,项目显示为null
- 如果集合在MeteorJS中为null或不为null,则显示模板
- TypeError:document.getElementById(..)为null,但不会停止显示
- 使用jquery或javascript显示null cookie值为空白空间
- getElementById()总是显示NULL状态
- Javascript变量未解析,显示为空白或null
- 当显示的内容在数据库中为NULL值时隐藏DIV
- 当JavaScript字符串等于null时,显示从DB获得的空字符串
- 如何保持null从显示在internet explorer