0

I have a case where two condition need to check for disabling button.

sample code , the way i have did

<div class="{{if isallowed 'notallowed'}} {{if isloading 'notallowed'}}">Submit</div>

Thanks.

dilip kumar
  • 377
  • 4
  • 13

3 Answers3

1

I like using ember-truth-helpers for the general case:

{{#if (and foo bar)}} foobar! {{/if}}

For tweaking classes (components only), I use classNameBindings.

classNameBindings: [isUrgent]

This adds class is-urgent to component if isUrgent is true in component context.

AlexMA
  • 9,842
  • 7
  • 42
  • 64
0

You can do it like this:

<div class={{unless isallowed 'notallowed' (if isloading 'notallowed')}}>Submit</div>
Ahmet Emre Kilinc
  • 5,489
  • 12
  • 30
  • 42
0

we can achieve this by using helper.

I have created helper for this and working fine for me.

Helper 'isany-true'

import Ember from 'ember';

export function anytrue(params) {
    return params.includes(true)
}

export default Ember.Helper.helper(anytrue);

Example

<div class="{{if (isany-true isdisableprev isloading) 'notallowed'}}">Submit</div>
dilip kumar
  • 377
  • 4
  • 13
  • Alexma answer is the right choice. you can use ember-truth-helper addon like this `class={{if (or isdisableprev isloading) 'notallowed'}}` . – Ember Freak Nov 29 '17 at 11:20