I have in my index.html two separate places where I declare:
<div ng-controller="ParentController>
<div id="box1" ng-controller="SameController">
Box1 {{test}} <button ng-click="changeMe()">Click</button>
</div>
<div id="box2" ng-controller="SameController">
Box2 {{test}}
</div>
</div>
Initially in SameController, $scope.test = "One" I want to make it so that when the user clicks the "Click" button, then {{test}} text will change to "Two" in both places (box1 and box2) (what the changeMe function does).
The problem is when I click, only the message in "Box1" changes to "Two", but not the message in "Box2". I tried using: $scope.$parent.test = "One" and make it so that SameController points to it, but it does not seem to work either.
How can I get around this so that both box1 and box2 change the text content of {{test}} when the button is clicked? The more elegant the solution the better.