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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -