bie*_*ior 1 data-binding ember.js
我有一个简单的按钮,其中包含我绑定id的操作:
<button {{action goTo item}} {{bindAttr id="item.id"}} >{{item.name}}</button>
Run Code Online (Sandbox Code Playgroud)
这给了我id='123'
,是可以以某种方式为id加上前缀.id='navbtn_123'
?
小智 6
在"项目"定义中使用计算属性
idPrefix: 'navbtn_',
idForElement = function(){
return this.get('idPrefix')+this.get('id')
}.property('id','idPrefix')
Run Code Online (Sandbox Code Playgroud)
和你的把手
<button {{action goTo item}} {{bindAttr id="item.idForElement"}} >{{item.name}}</button>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
195 次 |
最近记录: |