Reputation: 517
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.
Upvotes: 0
Views: 99
Reputation: 517
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>
Upvotes: 0
Reputation: 10192
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.
Upvotes: 1
Reputation: 6895
You can do it like this:
<div class={{unless isallowed 'notallowed' (if isloading 'notallowed')}}>Submit</div>
Upvotes: 0