likeastore / ngDialog

Modals and popups provider for Angular.js applications
http://likeastore.github.io/ngDialog
3.14k stars 692 forks source link

closeThisDialog() from within a watcher #519

Open ntopulos opened 7 years ago

ntopulos commented 7 years ago

AngularJS 1.4.9
ng-dialog 0.6.4

Is it possible to close a modal from within a watcher that is inside this modal's controller? When I try, the modal closes, but Angular crashes with the error Error: C is null.

$scope.$watch(
  function(){ return GetNew(); },
  function(newVal) {
    if (newVal === true) {
      $scope.closeThisDialog();
    }
  },
  true
);