![](/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.