简体   繁体   English

AngularJS-观看模态窗口从另一个控制器关闭

[英]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). (我使用的dialog指令来自有角度的材料)。 How can I watch when dialog window is closed from main controller? 如何从主控制器关闭对话框窗口时观看?

Use the promise returned from the mdDialog : 使用从mdDialog返回的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()
 })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM