简体   繁体   中英

What is the proper way of using ng-repeat to set attributes on an element?

So I have the following 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>

I am getting an error from using {{player.lane}} in the this line:

<div lane="{{player.lane}}" class='dropbox' dropbucket>

My question is this: What is the proper way of using ng-repeat to set attributes on an element?

只需使用

<div lane="player.lane" class='dropbox' dropbucket>

Turns out I had a two way binding in the drag and drop directive that was set to lane. Once I removed that binding, everything worked as expected.

Thanks for the insight everyone..

Z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM