meteor - if is not equal in blaze 怎么写

标签 meteor meteor-blaze

我在 js 文件中有这个:

  isAdmin: function() {
    if (Meteor.user().roles[0] == "admin") {
        return true;
    } else {
        return false;
    }
},

在Html中我想说if admin ==false.怎么回事?

条件为真:我要假

  {{#if isAdmin}}
       ...
  {{/if}}

这样可以吗?

  {{#if !isAdmin}}
       ...
  {{/if}}

最佳答案

我猜你在找什么

{{#unless isAdmin}}
    ...
{{/unless}}

看看here在文档中。

顺便说一句,如果您使用的是 alanning:roles 包,它包含一个方便的 Blaze 小 helper 。

{{#unless isInRole 'admin'}}
    ...
{{/unless}}

希望对您有所帮助。

关于meteor - if is not equal in blaze 怎么写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43410427/

相关文章:

javascript - 进度条文字不显示

Meteor blaze 通过数组索引选择一个特定的项目

jquery - Meteor 0.9.1.1 中的 iCheck.js

Meteor.js - 如何从客户端观察 Changes()

javascript - Session 值应该在 Meteor 应用程序中的哪里启动?

脚本标签内的 Meteor 模板

jquery - 表内的语义 ui Accordion

meteor - 从 currentView 获取 jQuery 元素

meteor - 如何在初始页面加载时在 Meteor.js 应用程序的头部包含一个标签?

javascript - 制作 meteor 重新渲染 "unchanged"字段