Angular Bootstrap Modal leaves backdrop open

后端 未结 6 1411
你的背包
你的背包 2020-12-09 16:04

I\'m using AngularUI to integrate Bootstrap components in my Angular 1.4 app, such as Modals.

I\'m calling a Modal in my controller like so:

var mod         


        
6条回答
  •  攒了一身酷
    2020-12-09 16:39

    I am using Angular version 1.3.13 and have a similar issue. I been researching the problem and believe this bug extends from angular version 1.3.13 to 1.4.1 details here https://github.com/angular-ui/bootstrap/pull/3400

    And if you scroll to the bottom of that link you will see a post by fernandojunior showing the versions he tested and upgraded to still showing the same issue. He even created a plnker to simulate the issue http://plnkr.co/edit/xQOL58HDXTuvSDsHRbra and I've simulated the issue in the code snippet below using the Angular-UI modal code example.

    // angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
    
    angular
      .module('ui.bootstrap.demo', [
        'ngAnimate',
        'ui.bootstrap',
      ]);
    
    angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $modal, $log) {
    
      $scope.items = ['item1', 'item2', 'item3'];
    
      $scope.animationsEnabled = true;
    
      $scope.open = function (size) {
    
        var modalInstance = $modal.open({
          animation: $scope.animationsEnabled,
          templateUrl: 'myModalContent.html',
          controller: 'ModalInstanceCtrl',
          size: size,
          resolve: {
            items: function () {
              return $scope.items;
            }
          }
        });
    
        modalInstance.result.then(function (selectedItem) {
          $scope.selected = selectedItem;
        }, function () {
          $log.info('Modal dismissed at: ' + new Date());
        });
      };
    
      $scope.toggleAnimation = function () {
        $scope.animationsEnabled = !$scope.animationsEnabled;
      };
    
    });
    
    // Please note that $modalInstance represents a modal window (instance) dependency.
    // It is not the same as the $modal service used above.
    
    angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) {
    
      $scope.items = items;
      $scope.selected = {
        item: $scope.items[0]
      };
    
      $scope.ok = function () {
        $modalInstance.close($scope.selected.item);
      };
    
      $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
      };
    });
    
    
      
        
        
        
        
        
        
        
        
      
      
    
    
    Selection from a modal: {{ selected }}

提交回复
热议问题