ember-truth-helpers
ember-truth-helpers copied to clipboard
eq evaluates always false
I have this demo in Ember 2.4:
{{#each clients as |clientChoice|}}
{{clientId}} - {{clientChoice.id}}
{{eq clientId clientChoice.id}}
<br>
{{/each}}
And I get this evaluation in screen: 4 - 1 false 4 - 3 false 4 - 4 false 4 - 5 false
Why is this happening?
The complete code (I'm working with components): component.hbs:
<select class="form-control" onchange={{action "selectClient" value="target.value"}} id="selcl">
<option value="" disabled selected>{{title}}</option>
{{#each clients as |clientChoice|}}
<option value={{clientChoice.id}} selected={{eq clientId clientChoice.id}}>{{clientChoice.firstName}} {{clientChoice.lastName}}</option>
{{/each}}
</select>
{{clientId}}
{{#each clients as |clientChoice|}}
<br>
{{clientId}} - {{clientChoice.id}}
{{eq clientId clientChoice.id}}
{{/each}}
component.js
import Ember from 'ember';
export default Ember.Component.extend({
clientId: Ember.computed('clientId', function() {
return this.get('clientId');
}),
client: null,
clients: Ember.computed('clients', function() {
return this.get('clients');
}),
actions: {
selectClient(clientId) {
this.set('clientId', clientId);
console.log($("select").val());
}
}
});