Angularjs - 观察模态窗口从另一个控制器关闭

Angularjs - watch modal window close from another controller

本文关键字:另一个 控制器 窗口 观察 模态 Angularjs      更新时间:2023-09-26

我有主控制器

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

和对话连接者

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

(我使用的对话框指令来自角度材料)。如何观察主控制器关闭对话框窗口的时间?

使用从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()
 })