I want to call a function or change the value of variable/s which is there inside another controller. I looked online for the solution and understood that I have to create a service
and use it inside both the controller, however I am not able to understand that how service
will have access to $scope.home_main
and $scope.home_main
variables as they are in different scope
.
JS
app.controller('Controller1', function ($scope, $window) {
$scope.toggle = function() {
$scope.home_main = !$scope.home_main;
$scope.full_page_place_holder = !$scope.full_page_place_holder;
};
});
app.controller('Controller2', function ($scope, $window) {
$scope.onTabSelect=function(){
// here I want to call toggle function which is inside another controller.
};
});
Updated HTML
<div ng-controller="Controller1">
<div ng-hide="home_main"></div>
</div>
<div ng-controller="Controller2">
<div ng-hide="full_page_place_holder"></div>
</div>