javascript - data-binding not working on nested ng-repeat -
when nesting ng-repeat
seems clicking on toggle button updates addon in every 'pair' (the first ng-repeat). can explain me why case , can fix it? check link above custom directive code...
<div ng-repeat="pair in pairs track $index"> <h3>pair {{ $index + 1}}</h3> <div class='fieldrow'> <button ng-repeat="addon in addons track $index" toggle-button="addon.added">{{addon.name}} (£{{addon.price}})</button> </div> </div>
what pair , addon, , how related. right now, though have nested ng-repeat, have independent data structures, addons array same each pair. trott.
based on insight, changed ng-repeat="addon in addons track $index"
ng-repeat="addon in pair.addons track $index"
problem solved, thanks!
Comments
Post a Comment