Ember-paper and class?

138 Views Asked by At

I'm working on a project made with Ember.js I'm using ember-paper addon for buttons and also Ember-intl addon to translate my application (English and French).

I have a basic HTML button with this code:

<button class={{if model.active "active"}} {{action "changeLocale" model.locale}}>{{model.locale}}</button>

But when I use ember-paper with this kind of code :

{{#paper-button accent=true}}Test{{/paper-button}}

I can't find a way to add my if statement and the action.

{{if model.active "active"}} {{action "changeLocale" model.locale}}>

Do you know how to do that?

1

There are 1 best solutions below

0
rinold simon On BEST ANSWER

Working Twiddle

1) You can call your action using onClick option inside {{#paper-button}} component.

2) You can use disabled and accent boolean options to set true or false based on your condition model.active

{{#paper-button
  onClick=(action "someAction")
  accent=true
  disabled=(unless model.active true)
  accent=(if model.active true)
}}
  Test
{{/paper-button}}