vitalym
vitalym

Reputation: 893

Angularjs - watch modal window close from another controller

I have main controller with

$scope.showDialog = function(ev) {
    $mdDialog.show({
      controller: 'DialogController',
      templateUrl: 'partials/dialog.tmpl.ejs',
      targetEvent: ev
    })
};

and dialog contoller with

$scope.hide = function() {
    $mdDialog.hide();
};

(The dialog directive I'm using is from angular material). How can I watch when dialog window is closed from main controller?

Upvotes: 0

Views: 984

Answers (1)

eladcon
eladcon

Reputation: 5825

Use the promise returned from the mdDialog:

 $mdDialog.show({
      controller: 'DialogController',
      templateUrl: 'partials/dialog.tmpl.ejs',
      targetEvent: ev
 }).then(function(data) {
      // dialog was hidden with $mdDialog.hide()
 }, function() {
      // dialog was canceled with $mdDialog.cancel()
 })

Upvotes: 1

Related Questions