2016-11-16 123 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