I am new to AngularJS. Here's my question.
I have a page-level variable like this var isStateA = false
. I have assigned this variable to my controllers variable like this:
var isStateA = false;
app.controller('AController',function($scope){
$scope.shouldShow = isStateA;
});
app.controller('BController',function($scope){
$scope.shouldShow = !isStateA;
});
The shouldShow
properties are bind to ng-show
accordingly.
The expected behavior is when I change isStateA
to be true
. The values in scope of the two controller should change, and as a result, they should perform show/hide logic.
But this is not happening with my code above. I am wondering if there's a way to do it? Like when the isStateA
value changed, notify related properties to apply the latest value?
Thank you