![](/img/trans.png)
[英]AngularJs Directive: How to dynamically set attributes on ng-repeat element
[英]What is the proper way of using ng-repeat to set attributes on an element?
所以我有以下div:
<div ng-repeat="player in playersScores" class="sb_lane">
<div class='sb_animation drop'></div>
<div lane="{{player.lane}}" class='dropbox' dropbucket>
<div class='sb_lHeader'>
<div class="drop">Lane {{player.lane}}</div>
<div class="drop">{{player.player}}</div>
</div>
<div class="sb_rScore drop">Run : {{cRun}} of {{tRun}}
<div>Run Score</div>
<div >{{player.rScore}}</div>
</div>
<div class="sb_tScore drop">Game Score
<div > {{player.gScore}}</div>
</div>
</div>
</div>
我在此行中使用{{player.lane}}时遇到错误:
<div lane="{{player.lane}}" class='dropbox' dropbucket>
我的问题是:使用ng-repeat设置元素属性的正确方法是什么?
只需使用
<div lane="player.lane" class='dropbox' dropbucket>
原来,在设置为lane的拖放指令中,我有两种绑定方式。 一旦删除绑定,一切都会按预期进行。
感谢大家的见解。
ž
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.