关闭对话框时留下灰色阴影

时间:2017-08-02 13:15:34

标签: javascript css angularjs modal-dialog

我在我的应用中使用角度ModalService进行对话。当我想要关闭对话框时,留下黑色阴影。我的控制员:

angular.module("app")
.controller('TreeController', ['$scope', 'asyncService', 'ModalService', 'dataService',
    function ($scope, asyncService, ModalService, dataService) {

        $scope.showJobModal = function (id) {
            dataService.setCurrentJobId(id);
            ModalService.showModal({
                    templateUrl: 'modal.html',
                    controller: "ModalController",
                    preClose: function (modal) {
                        modal.element.modal('hide');
                    }
                }
            ).then(function(modal) {
                modal.element.modal();
                modal.close.then(function() {
                    console.log("closed job modal")
                });
            });
        }

    }]);

angular.module('app').controller('ModalController', ['$scope', 'asyncService', 'dataService', 'ModalService', 'close',
    function ($scope, asyncService, dataService, ModalService, close) {
        asyncService.getJob(dataService.getCurrentJobId()).then(function (response) {
            $scope.job = response;
        });

        $scope.close = function() {
            close(500);
        };

    }]);

当我点击外部对话框时,它关闭就好了。但是当我想在$ scope.close上关闭它时,黑色阴影留下了。我试过这个:close modal release,但一切都是一样的。有什么建议吗?

2 个答案:

答案 0 :(得分:1)

$scope.closeModal = function () {
    $uibModalStack.dismissAll();
}

$uibModalStack注入您的控制器

答案 1 :(得分:1)

使用$ uibModal https://jsfiddle.net/awolf2904/74exww04/

Example:
     $scope.dialogOpen = function () { 
        var modal = $uibModal.open ({
          backdrop: false,
          templateUrl: './abc.html',
          controller: function ($scope) {
            $scope.close = function () {
              modal.dismiss('cancel');
            };
          };
       });
    };