I am currently working on establishing a connection between different controllers to control the visibility of a div based on radio button selection in another controller.
With some assistance, I have made progress in getting this functionality partially working. Here is what has been accomplished so far:
I created a factory to facilitate communication between the two controllers. Within this factory, there is an update function that is triggered by ng-change
to update the string with the newly selected value.
.factory("sessionCheck", function() {
var sessionCheck = {};
var update = function (index) {
console.log(index);
sessionCheck = index;
return sessionCheck;
};
return { update: update }
In the first controller, the function is invoked when ng-change
occurs on the radio buttons:
//bring in session check, (injected above)
$scope.updateChecker = sessionCheck;
$scope.sessionChange = function(){
$scope.updateChecker.update($scope.opMeasure);
};
The issue lies in retrieving this updated information in another controller and utilizing it to either hide or show a particular div.
It would be beneficial if a default value, such as "1", could be returned prior to the ng-change event. Additionally, it would be ideal to find a more straightforward approach that directly reads from the model of the radio buttons (opMeasure) instead of relying on the ng-change
event trigger.
I have been grappling with this problem for quite some time now and any guidance or suggestions would be greatly appreciated. Thank you!