EmberJS - 模板条件 Unless

它仅执行 false 语句块。

语法

{{#unless falsy_condition}}
    //语句块
{{/unless}}

示例

下面给出的示例展示了 Ember.js 中 except 条件帮助程序的使用。在 app/templates/ 下创建一个名为 application.hbs 的模板,代码如下 −

{{#unless check}}
   <h3> boolean value is {{check}}</h3>
{{/unless}}

现在创建名为 application.js 的控制器文件,该文件将在 app/controller/ 下使用以下代码定义 −

import Ember from 'ember';

export default Ember.Controller.extend ({
   bool: false,
   check: function () {
      return this.bool;
   }.property('content.check')
});

输出

运行 ember 服务器,您将收到以下输出 −

Ember.js Template Condition Unless

emberjs_template.html