问题
{{#each App.SampleViewController}}
{{#view App.SampleView contentBinding="this" sort-date="content.sortDate" name="content.name"}}
<a href="#" onclick="App.loadSampleDetails(this);" {{bindAttr id="content.id"}}>
{{/view}}
{{/each}}
How to add custom attributes/generic attributes (like in the above example sort-date/name attributes) to the view element from the xhandlebars script tag, I know that using attributeBindings we can add, but I have the dynamic data coming from controller through each.
回答1:
You can use the attributeBindings property to define additional attributes that will get added to the DOM output for a view. See the "HTML Attributes" section in the Ember.View docs: http://docs.emberjs.com/#doc=Ember.View&src=false
来源:https://stackoverflow.com/questions/10396017/bind-custom-attributes-on-ember-view-with-controller-data-in-xhandlebars-script