Search code examples
ember.jshandlebars.jshtmlbars

Is it possible to write conditional check for two variable in one conditional check


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.


Solution

  • 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>