I have a DIV with ng-show.
When I run ng-click on an element outside of the DIV, it works fine and I can hide it.
When I run ng-click on an element inside of the DIV, it does not work. I can see the variable beeing changed when i console.log it, but the view will not update.
I have tried to use $scope.$apply() but it gets an error and says it is already running $apply().
Parts of controller:
$scope.selectedActivity = { "dayNr": 0, "actNr": 0 }; $scope.resetSelectedActivity = function () { console.log("SelAct: ", $scope.selectedActivity); $scope.selectedActivity.dayNr = -1; $scope.selectedActivity.actNr = -1; console.log("SelAct: ", $scope.selectedActivity); }; $scope.setSelectedActivity = function (dayNr, actNr) { console.log("SelAct: ", $scope.selectedActivity); $scope.selectedActivity.dayNr = dayNr; $scope.selectedActivity.actNr = actNr; console.log("SelAct: ", $scope.selectedActivity); }; Parts of HTML:
<div ng-repeat="x in xs"> <ion-scroll> <div ng-repeat="y in ys track by $index"> <div ng-click="setSelectedActivity($parent.$index, $index)"> <!--THE PROBLEM IS HERE--> <div ng-show="selectedActivity.dayNr == $parent.$index && selectedActivity.actNr == $index"> <div> <!--THIS LOGS OUT CORRECT VALUES BUT NG-SHOW IS NOT UPDATED--> <div ng-click="resetSelectedActivity()"> Reset </div> </div> </div> <div> <img src="img/checkButtonOverlay.png" /> </div> </div> <!--THIS LOGS OUT CORRECT VALUES AND NG-SHOW _IS_ UPDATED--> <button ng-click="resetSelectedActivity()">reset</button> </div> </ion-scroll> </div> Please note that i have removed A LOT from the code because of confidentiality, but the principle should be the same.
Thank you!