I am facing an issue where I need to update a variable based on changes in another scope.
$scope.switch = true;
var thing;
if ($scope.switch == false) {
thing = "givesFalse";
}
else {
thing = "givesTrue";
};
this.thingscope = thing;
Essentially, when the value of $scope.switch
is changed to false, this.thingscope
should output givesFalse
. To achieve this, I utilize ng-click:
<div ng-controller="myCtrl as myCtrl" ng-app="myApp">
{{myCtrl.thingscope}}
<br>
<a ng-click="switch = !switch">{{switch}}</a>
</div>
Although the scope updates correctly, the variable thing
does not seem to update simultaneously. For a working example, please refer to the following Plunkr: here. Thank you for your assistance!