简体   繁体   English

在 Handlebars/HtmlBars 模板中添加 AND 条件

[英]Add AND condition in Handlebars/HtmlBars template

In my Ember project, I have a button as below;在我的 Ember 项目中,我有一个如下按钮;

{{my-button label="Add"  enabled=(lt gridItems.length maxRecordsInGrid)}}

Currently I have the "enabled" property based on gridItems.length < maxRecordsInGrid I want to add a 2nd condition to this ie if a property called "enableBtn" is true目前我有基于 gridItems.length < maxRecordsInGrid 的“启用”属性我想为此添加第二个条件,即如果名为“enableBtn”的属性为真

So, essentially, I want the "enabled" property to be an AND between;因此,本质上,我希望“启用”属性是 AND 之间的;

  1. gridItems.length < maxRecordsInGrid gridItems.length < maxRecordsInGrid
  2. enableBtn is true enableBtn 为真

Is it possible to do this directly in the template using some inbuilt HTMLBars condition without the need of explicit helpers?是否可以使用一些内置的 HTMLBars 条件直接在模板中执行此操作而无需显式帮助程序?

This is not possible in ember itself.这在 ember 本身是不可能的。

You can use ember-truth-helpers for this.您可以为此使用ember-truth-helpers

There is an open RFC to add this to ember itself.有一个开放的 RFC可以将其添加到 ember 本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM