簡體   English   中英

如何僅關閉打開的mdDialogs之一? AngularJs

[英]How can I close just the one of the opened mdDialogs? AngularJs

我的應用程序中有3個打開的mdDialogs(未嵌套在控制器中),其中2個將鍵“ multiple”設置為true,因此它們不會彼此關閉。 當我在其中一個調用mdDialog.close()或mdDialog.hide()時,兩個子對話框都隱藏了。 有什么辦法可以將它們一對一地關閉嗎? [關閉]

在下面的“自定義預設”部分中, https: //material.angularjs.org/latest/api/service/ $ mdDialog。 您需要通過調用來創建創建實例對象

myPrompt = $mdDialog.prompt();

要么

myPrompt = $mdDialog.confirm(); 

或創建自定義預設,然后在顯示或關閉時使用該實例:

$mdDialog.show(myPrompt);
$mdDialog.close(myPrompt);

這是頁面的一部分:

// Dialog #1 - Show simple alert dialog and cache
// reference to dialog instance

function showAlert() {
  alert = $mdDialog.alert()
    .title('Attention, ' + $scope.userName)
    .textContent('This is an example of how easy dialogs can be!')
    .ok('Close');

  $mdDialog
      .show( alert )
      .finally(function() {
        alert = undefined;
      });
}
$mdDialog.show({
  templateUrl: 'dialog.html',
  controller: 'DialogCtrl',
  skipHide:true
})

這對我有用。 我正在使用angularjs-material 1.1.0-rc5

實際上,這是一個愚蠢的錯誤。.如果我們只運行$ mdDialog.hide(),在每個孩子的'multiple'設置為true的堆疊對話框中就足夠了。 關於我的問題,問題是我有兩個錯誤地調用了hide函數,因此,我關閉了兩個對話框。 我的壞問題是不必要的,但是對於新手來說可能很有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM