sammy34
sammy34

Reputation: 5497

Ember bind attribute using truth helper

I'm using Ember v1.13 and would like to render the checked attribute of an input element based on the result of an ember-truth-helpers expression. The following DID NOT work for me:

<input type="radio" checked={{(eq arg1 arg2)}}>

<input type="radio" checked={{if (eq arg1 arg2) true false}}>

Is there a way to do this, or do I have to resort to the following (which works)?

  {{#if (eq arg1 arg2)}}
      <input type="radio" checked>
  {{else}}
      <input type="radio">
  {{/if}}

Upvotes: 1

Views: 321

Answers (1)

Daniel
Daniel

Reputation: 18692

Try this:

<input type="radio" checked={{eq arg1 arg2}}>

Or better, use {{input}} helper:

{{input type='radio' checked=(eq arg1 arg2)}}

Upvotes: 2

Related Questions