This issue with Angular has been widely discussed online, but I ask for your patience. I have tried various solutions without success. Here is a simplified version of my code:
View:
<div ng-hide="{{beHidden}}"></div>
Controller:
// Set beHidden to initially be false (Works when set to true as well)
$scope.beHidden = false;
// A popup prompts the user to choose whether to hide the div
var confirmPopup = $ionicPopup.confirm({
title: 'Hidden Div',
template: 'Do you want to hide the div?',
cancelText: 'No',
okText: 'Yes'
}).then(function(res) {
if(res) {
// User chose to hide div
$timeout(function() {
$scope.beHidden = true;
});
} else {
// User chose NOT to hide div
$timeout(function() {
$scope.beHidden = false;
});
}
});
However, this approach does not work. I have tried using $scope.$apply, but encountered an error stating "digest already in progress". I have also used $timeout without errors, but the view still doesn't update to hide the div when the user chooses to do so. Any suggestions?
And yes, I am correctly injecting $timeout into the controller...