2016-11-16 119 views
1

我正在使用角度材质。我正在使用$ mdDialog在我的应用程序上创建一个弹出窗口。一切工作正常,除了$ mdDialog.hide()不工作。

 $ctrl.footerModal = function() { 
      $mdDialog.show({ 
       template: '<md-dialog aria-label="Privacy Policy">' + 
       '<md-dialog-content>' + 
       '<div class="md-dialog-content">' + 
       '<h2>Privacy Policy</h2>' + 
       '<p> sum has been the industrys standard dummy text ever since the 1500s, when an unknown printer ' + 
       'took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, ' + 
       'but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s ' + 
       ' with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desk</p>' + 
       '<p>' + 
       '</div>' + 
       '</md-dialog-content>' + 
       '<md-dialog-actions layout="row">' + 
       '<span flex>' + '</span>' + 
       '<md-button ng-click="$ctrl.cancel()">' + 
       'Ok' + 
       '</md-button>' + 
       '</md-dialog-actions>' + 
       '</md-dialog>', 
       parent: angular.element(document.body), 
       clickOutsideToClose: true 
      }); 
      $ctrl.cancel = function() { 
       $mdDialog.hide(); 
      }; 
     } 

谁能告诉我我在做什么错在这里

+0

当你使用'$ mdDialog.hide()'? –

+0

我已经更新了代码。 – Shareer

回答

2

你应该使用.hide

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

编辑:

$ctrl.cancel功能应该放在外面为拉梅什提到

DEMO

+0

为什么downvote? – Sajeetharan

+0

他还使用同样的方法 –

+0

@RameshRajendran不,他正在使用.cancel,现在他已编辑 – Sajeetharan

0

请编写代码$ctrl.footerModal功能之外,

你的代码应该是

$ctrl.footerModal = function() { 
      $mdDialog.show({ 
       template: '<md-dialog aria-label="Privacy Policy">' + 
       '<md-dialog-content>' + 
       '<div class="md-dialog-content">' + 
       '<h2>Privacy Policy</h2>' + 
       '<p> sum has been the industrys standard dummy text ever since the 1500s, when an unknown printer ' + 
       'took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, ' + 
       'but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s ' + 
       ' with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desk</p>' + 
       '<p>' + 
       '</div>' + 
       '</md-dialog-content>' + 
       '<md-dialog-actions layout="row">' + 
       '<span flex>' + '</span>' + 
       '<md-button ng-click="cancel()">' + 
       'Ok' + 
       '</md-button>' + 
       '</md-dialog-actions>' + 
       '</md-dialog>', 
       parent: angular.element(document.body), 
       clickOutsideToClose: true 
      }); 
     } 

$ctrl.cancel = function() { 
      $mdDialog.hide(); 
     }; 
+0

我试过了。没有工作:( – Shareer