【问题标题】:Bootstrap Modal: Content from html page does not show within the modal引导模式:来自 html 页面的内容未显示在模式中
【发布时间】:2017-01-07 02:46:50
【问题描述】:

我创建了一个按钮,当您单击它时会出现一个模式。 代码如下:

<li style="float: right;">
     <button id="myBtn" data-target="#myModal" ng-click="printDivModal('rollup-tab')">Modal Test</button>
</li>

在 js 中,ng-click 应该打开一个模型,其中包含来自 stackModal.html 的数据 这是js文件中的代码:

$scope.printDivModal = function(divName) {
            console.log('opening pop up');
            var ModalInstance = $uibModal.open({
                //animation: $ctrl.animationsEnabled,
                templateUrl: 'app/views/modals/stackedModal.html',
                size: 'lg',
                /*
                controller: function($scope) {
                    $scope.name = 'top';  
                  }
                 */
            });
        }

这是模型的代码(stackedModal.html):

 <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">The Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Text inside the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>

    </div>
  </div>

当我单击模型测试按钮时,我看到的只是屏幕上显示的一个白色小矩形。 stackedModal html 页面中没有显示任何内容。为什么是这样?谢谢。

【问题讨论】:

  • 您是否在控制台中收到“正在打开弹出窗口”的消息?
  • @StefanVilbrandt 是的,我愿意
  • 使用javascript模型打开时也不需要data-target属性。

标签: html angularjs angular-ui-bootstrap bootstrap-modal angularjs-ng-click


【解决方案1】:

只需删除模态包装器 div,bootstrap-modal 会为您完成。 您只需要放置模态内容:

stackedModal.html:

<div class="modal-header">
  <button type="button" class="close" data-dismiss="modal">&times;</button>
  <h4 class="modal-title">The Modal Header</h4>
</div>
<div class="modal-body">
  <p>Text inside the modal.</p>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>

【讨论】:

    猜你喜欢
    • 2019-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    相关资源
    最近更新 更多