javascript - Access ng-repeat's item scope -
i've got table rows use respective scope variables conditional rendering:
<tr ng-repeat="row in data"> <input type="text" data-ng-show="editmode" data-ng-model="row.smth"/>
so input shown when row scope variable editmode
set true, works fine.
now i'd add row dynamically:
$scope.data.push(my_new_row)
that works great too. i'd set new row's scope variable editmode
something, , i'm out of ideas.
i know there's undocumented way use $$childhead etc that's not elegant.
you can track items using $index. can use index decide show/hide item. can implementing function show/hide logic , pass in index. example:
<div ng-repeat="row in data track $index"> <input type="text" data-ng-show="geteditmode($index)" ng-model="row.smth[$index]"> </div>
have @ this.
Comments
Post a Comment