Reputation: 1549
I try to do it like that:
{{#each item in controller.records}}
<li {{bind-attr class=":message (compare controller.currentUser.id item.user_id)::mes-self" >
.....
</li>
{{/each}}
And mes-self
didn't add to class attribute. Is there possibility to do that?
Upvotes: 0
Views: 47
Reputation: 18672
I see 3 problems in your code:
{{each in}}
helper. It's deprecated now.{{bind-attr}}
helper.{{bind-attr}}
+ ::
and that's unlikely to work.Instead, please try:
{{#each controller.records key='id' as |item|}}
<li class="message {{if (compare controller.currentUser.id item.user_id) '' 'mes-self'}}">
.....
</li>
{{/each}}
I'm assuming you're using Ember v1.13+ and {{compare}}
expression was declared(you've created this helper) and it returns true
if passed values are the same.
Upvotes: 1