Bind custom attributes on Ember view with controller data in xhandlebars script

℡╲_俬逩灬. 提交于 2019-12-11 14:53:06

问题


{{#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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!