I have a set of items in a model tree, which are shown via ng-repeat. Each item in ng-repeat has its own controller (which lets each item have its own properties). Each item has a selected property that is only important per-session, so I'm not saving it as an attribute on the model tree, which is synced to a server.
function ItemCtrl($scope) {
$scope.selected=false;
$scope.Select = function () {
$scope.selected = true;
};
};
Now, when I create a new item by adding it to the model tree, I want to access its scope in the entry created automatically by ng-repeat in order to flip its "selected" variable to true, but I don't know how to access that. I've made a quick fiddle to illustrate my problem. Thoughts?
You can do it with the $rootScope. Have updated the fiddle link.
Add $rootScope to the ItemCtrl and the Select function.