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"); }; };
Comments
Post a Comment