Emberjs bindAttr inside of #each
- by Andrej Kaurin
Code for view is
Ember.View.extend({
template: Ember.Handlebars.compile(html), // html is in string
content: function() {
return [
{ Title: "Dashboard", ID: "dashboard" },
{ Title: "Invoices", ID: "invoices" },
{ Title: "Expenses", ID: "expenses" },
{ Title: "People", ID: "people" },
{ Title: "Reports", ID: "reports" },
{ Title: "Settings", ID: "settings" }
]},
iconClass: "icon icon-dashboard"
});
Template (show above as "html") looks like this:
<ul>
{{#each link in content}}
<li>
<a>
<span class="icon" {{bindAttr class="iconClass"}}></span>
<span class="title">{{link.Title}}</span>
</a>
</li>
{{/each}}
</ul>
Am I doing something wrong with scope or?