$mdDialog [$rootScope:inprog] $digest already in progress

450 views Asked by At

When calling a $mdDialog and then calling one more $mdDialog right after the first one - then this error appears 3 times in a row.

enter image description here

No I do not use $scope.apply() or $scope.$digest() anywhere in my code.

$scope.$$phase is null at the time of the error

The full code is too big to post here, and the error happens inside the $mdDialog minified functions.

Anyway this is where we call $mdDialog:

  $scope.$on('openDialog', function(event, data){

  $mdDialog

        // Open the dialog
        .show({
            template: require('./confirmDialog.html'),
            parent: angular.element(document.body),
            controller: function($scope) {
                var vm = this;
                vm.header   = data.header;
                vm.question = data.question;
                vm.cancel = function() {
                    $mdDialog.cancel();
                }
                vm.yes = function() {
                    $mdDialog.hide('yes');
                }
                vm.no = function() {
                    $mdDialog.hide('no');
                }
            },
            controllerAs: 'vm',
            clickOutsideToClose:true
        })
        // React to answer
        .then(function(modalActionResult){    
            console.log("scope phase", $scope.$$phase);      
            $scope.modalActions({'performAction': modalActionResult, 'type': data.type});
        })
        // Catch any errors
        .catch(function(){

        })
        // Close and kill listeners?
        .finally(function() {

        });

    }); 
0

There are 0 answers