Emberjs bindAttr inside of #each

Posted by Andrej Kaurin on Stack Overflow See other posts from Stack Overflow or by Andrej Kaurin
Published on 2012-10-11T21:33:41Z Indexed on 2012/10/11 21:37 UTC
Read the original article Hit count: 436

Filed under:

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?

© Stack Overflow or respective owner

Related posts about ember.js