Having trouble passing a scope into a function and getting it to work properly. Here's the code snippet -
ng-click="clickFunction(scope1)"
//the function
$scope.clickFunction = function(passedScope){
passedScope = false;
console.log($scope.scope1);
Basically, I want to pass the scope and set it to false on click. However, when I log the scope after changing it, it still shows as true. I also attempted -
$scope.passedScope
The goal is to change $scope.scope1 to false. It is initially set as true at the top of the controller and controls a nearby button with ng-disabled="!scope1". Simply toggling scope1 on click doesn't work because there's a confirmation modal involved which sets the passed scope to false. Instead of directly calling the scope, I'm trying to create a reusable function that can update different scopes by passing them as arguments.
I thought passing the scope through the function would work.
Thanks!
Update: Thanks to @Josep's guidance today, I managed to find a workaround by passing the scope as a string like this
ng-click="clickFunction('scope1')"
And then using
$scope[passedScope] = false;