I have a variable that I want to change when another scope changes its value.
$scope.switch = true;
var thing;
if ($scope.switch == false) {
thing = "givesFalse";
}
else {
thing = "givesTrue";
};
this.thingscope = thing;
So when I change $scope.switch
value to false, this.thingscope
should output givesFalse
. In order to change the scope value, I use ng-click:
<div ng-controller="myCtrl as myCtrl" ng-app="myApp">
{{myCtrl.thingscope}}
<br>
<a ng-click="switch = !switch">{{switch}}</a>
</div>
But even that I can see that the scope does update, the variable thing
doesn't seem to update at the same time. You can see the working plunkr here. Thanks in advance!