使用内联"如果帮助"在Ember中使用逻辑运算符

时间:2017-03-24 09:08:22

标签: ember.js handlebars.js

所以基本上,如果索引等于 0 ,我只想添加有效类。

{{#each posts as |post index|}}
  <div class="item {{ 'add active class here if index is 0' }}">
  </div>
{{/each}}

我知道使用此代码,{{if index == 0 'active'}}无法正常工作,因为ember中内置的 if helper 不支持逻辑运算符。 Ember Conditionals

那么实现这个目标的方法是什么?

1 个答案:

答案 0 :(得分:0)

看看ember-truth-helpers插件。

同样ember-math-helpers对数学运算也有好处。

相关问题