我已经实现了模态指令,并将$modal.open选项背景设置为false.但是,现在我可以触发多个模态打开.有一种方法可以防止触发按钮在一个模态打开后触发吗?
var accountSummaryCtrl = function ($scope,$modal,$log) { $scope.open = function () { var modalInstance = $modal.open({ templateUrl: '/Apps/generic/modal/Templates/AccountSummary.html',controller: ModalInstanceCtrl,backdrop: false }); modalInstance.result.then(function (selectedItem) { $scope.selected = selectedItem; },function () { $log.info('Modal dismissed at: ' + new Date()); }); }; };
谢谢
使用布尔标志来避免它:
原文链接:https://www.f2er.com/angularjs/140876.htmlvar accountSummaryCtrl = function ($scope,$log) { var opened = false; $scope.open = function () { if (opened) return; var modalInstance = $modal.open({ templateUrl: '/Apps/generic/modal/Templates/AccountSummary.html',backdrop: false }); opened = true; modalInstance.result.then(function (selectedItem) { $scope.selected = selectedItem; opened = false; },function () { $log.info('Modal dismissed at: ' + new Date()); opened = false; }); }; };