2017-04-14 47 views
0

等於我有這個在js文件:怎麼寫,如果不是在大火

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

在HTML中我想說,如果管理員== false.how是什麼呢?

這是真實的情況:我想假

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

它是更多鈔票這樣嗎?

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

回答

4

我猜你是什麼尋找是

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

查看文檔here

順便說一句,如果你使用的是alanning:roles軟件包,它包含了Blaze的一個方便的小幫手。

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

希望有所幫助。

+0

是的兩個都是正確的,也是我自己的答案,但我把你的綠色勾號,因爲它更一般:) – Mehr

0

的方法之一是這樣的:

{{#if $eq isAdmin false}} 
    ... 
{{ /if }} 

的另一種方式是這樣的:

Template.registerHelper('equals', function (a, b) { 
    return a === b; 
}); 

然後在HTML:

{{#if equals isAdmin 'false'}} 
    ... 
{{/if}}