模态窗口具有大背景

时间:2016-11-11 13:47:52

标签: angularjs bootstrap-modal ui.bootstrap

我在其中一个视图上使用了iu.bootstrap.modal弹出窗口。模态窗口正确显示,除了它看起来像是在更大的白框内。

是什么原因导致此白框出现在我的模态窗口后面?

以下是我的观点:

<button type="button" id="btnModal" name="modal1" ng-click="openModal()" class="btn btn-primary pull-right">Open Modal</button>

<!--Modal-->
<script type="text/ng-template" id="myModal.html">
<div class="modal-content">
<div class="modal-header">
    <h3 class="modal-title">{{title}}</h3>
</div>
<div class="modal-body">
    <span id="error-message" class="text-danger" style="white-space:pre">{{message}}</span>
</div>
<div class="modal-footer">
    <button id="btn-ok" class="btn btn-primary" type="button" ng-click="ok()">OK</button>
</div>
</div>    
</script>

我的控制器

  $scope.openModal = function () {
  var title = "Modal Title";
  var message = "Modal Message";

  var modalInstance = $uibModal.open ({
      animation: true,
      templateUrl: 'myModal.html',
      size: 'sm',
      controller: function ($scope) {
        $scope.title = title;
        $scope.message = message;
        $scope.ok = function () { modalInstance.dismiss() };
    }
  });
};

是什么原因导致窗口出现在模态后面?

enter image description here

1 个答案:

答案 0 :(得分:3)

在ui.bootstrap文档(https://angular-ui.github.io/bootstrap/#/modal

<script type="text/ng-template" id="myModalContent.html">
        <div class="modal-header">
            <h3 class="modal-title" id="modal-title">I'm a modal!</h3>
        </div>
        <div class="modal-body" id="modal-body">
            <ul>
                <li ng-repeat="item in $ctrl.items">
                    <a href="#" ng-click="$event.preventDefault(); $ctrl.selected.item = item">{{ item }}</a>
                </li>
            </ul>
            Selected: <b>{{ $ctrl.selected.item }}</b>
        </div>
        <div class="modal-footer">
            <button class="btn btn-primary" type="button" ng-click="$ctrl.ok()">OK</button>
            <button class="btn btn-warning" type="button" ng-click="$ctrl.cancel()">Cancel</button>
        </div>
    </script>

<div>课程没有modal-content。但是你在模态的开头就有了。 modal-content是一个css Bootstrap类,它可能会导致问题。