0

在我打字稿中編寫的角度應用程序中,我使用UI網格引導模式中顯示一些數據。我想要實現的是在點擊網格行中的任何一列時,模式關閉。我怎樣才能做到這一點?我沒有使用$ modal$ modalInstance現在,因爲它是SPA,所以不需要這個。有沒有辦法不使用它們,並調用modal.dismiss()onRowSelection如何關閉在UI網格中點擊引導模態角

+0

我使用$ modal和$ modalInstance有一個SPA(如在單頁面應用程序中?),我不認爲它們是相關的。你有任何代碼向我們展示?一個沉重的人可能? – klskl

+0

$ modal和$ modalInstance之間沒有任何關係,並有一個SPA應用程序。如果你想與模態交互使用$ modalInstance – Walfrat

回答

0

您可以使用下面的代碼打開模態。

var modalInstance = $modal.open({ 
    template: require('./modal.html'), 
    controller: require('./search.controller'), 
    controllerAs: 'searchModalInstance', 
    scope: $scope, 
    size: 'lg', 
    windowClass: 'search-modal-popup' 
    }); 

之後,添加modalInstance範圍爲UI網appScopeProvider UI-Grid GridOptions

一樣,uiGridOption.appScopeProvider = modalInstance;

現在,您可以通過從UI格調用函數close()關閉模式。

+0

有沒有什麼辦法可以在不使用這個打開函數的情況下關閉模態?這部分對我的應用來說真的是不必要的代碼片段。 – cAMPy

+0

@cAMPy然後你可以使用$ modaStack.getTop().key.close()來關閉模態。 $ modalStack.getTop()返回當前打開的模態對象。 – Amit

+0

阿米特遺憾的是這不起作用。我得到en錯誤: 錯誤:_this。$ modalStack.getTop(...)未定義。我添加了我的模式到uiGridOptions: appScopeProvider:document.getElementById(「idOftheDivWhichClassIsModalFade」), – cAMPy