angularjs - Reference new scope created by adding an object to ng-repeat -


i have set of items in model tree, shown via ng-repeat. each item in ng-repeat has own controller (which lets each item have own properties). each item has selected property important per-session, i'm not saving attribute on model tree, synced server.

function itemctrl($scope) {      $scope.selected=false;      $scope.select = function () {          $scope.selected = true;     };  }; 

now, when create new item adding model tree, want access scope in entry created automatically ng-repeat in order flip "selected" variable true, don't know how access that. i've made quick fiddle illustrate problem. thoughts?

you can $rootscope. have updated fiddle link.

add $rootscope itemctrl , select function.

function itemctrl($scope,$rootscope) {      $scope.selected=false;      $rootscope.select = function () {          $scope.selected = true;           alert("selected set true");     };  }; 

updated link fiddle


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -