简体   繁体   English

Angular-Bootstrap,无法显示模态

[英]Angular-Bootstrap, Can't get modal to appear

Here's a plunker that replicates the issue I'm having. 这是一个复制我正在解决的问题的掠夺者。

Long and short of it, I can get the backdrop to appear, and the console shows the modal being popped onto the DOM, but isn't visible. 它的长短不一,我可以让背景出现,控制台显示模式被弹出到DOM上,但是不可见。 Not sure if it's supposed to be popped onto a different element or if the visibility is supposed to be set manually somewhere, but I'm following along with the example code and can't make the actual modal dialog appear. 不确定它是否应该弹出到不同的元素上,或者是否应该在某处手动设置可见性,但是我跟随示例代码并且无法使实际的模态对话框出现。

Using Angular-UI 0.6 with Bootstrap 3.0 styles (though I've tried the older Bootstrap versions and multiple angular versions). 使用Angular-UI 0.6和Bootstrap 3.0样式(虽然我尝试过较旧的Bootstrap版本和多个角度版本)。

http://plnkr.co/edit/p23z5xnjQRmHu8MOfvcv?p=preview http://plnkr.co/edit/p23z5xnjQRmHu8MOfvcv?p=preview

So, I've managed to make this work, cobbling together various parts of an answer from here: https://github.com/angular-ui/bootstrap/issues/722 . 所以,我已经成功完成了这项工作,从这里开始拼凑答案的各个部分: https//github.com/angular-ui/bootstrap/issues/722 The trick is that, at least currently, angular-ui doesn't support Bootstrap 3.0 out of the box. 诀窍在于,至少目前,angular-ui不支持开箱即用的Bootstrap 3.0。 However, it can be worked around. 但是,它可以解决。 The HTML needs to be wrapped in a modal-dialog and modal-content, eg: HTML需要包含在模态对话框和模态内容中,例如:

<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">blah</div>
<div class="modal-body">blah</div>
<div class="modal-footer">blah</div>
</div>
</div>

Then you also need to add some styles to your CSS: 然后你还需要为CSS添加一些样式:

.modal {
  display: block;
}

.modal-body:before,
  .modal-body:after {
    display: table;
    content: " ";
}

.modal-header:before,
.modal-header:after {
  display: table;
  content: " ";
}

Check below is the working Demo 检查下面是工作演示

Model Window Working in Angular-Bootstrap 在Angular-Bootstrap中工作的模型窗口

Working Demo 工作演示

Based on a discussion here , there are a couple of options: 根据此处的讨论,有几个选项:

  • use patched ui-bootstrap build with $modal fix for bootstrap3 使用修补的ui-bootstrap构建与$ modal修复bootstrap3
  • build your own ui-bootstrap distribution with bootstrap3 support, currently hosted in bootstrap3_bis2 branch on github. 使用bootstrap3支持构建您自己的ui-bootstrap发行版,目前托管在github上的bootstrap3_bis2分支中。
    • $ git clone https://github.com/angular-ui/bootstrap.git ui-bootstrap3 && cd ui-bootstrap3
    • $ git checkout bootstrap3_bis2
    • $ npm install
    • $ grunt
    • grab needed .js files from dist folder 从dist文件夹中获取所需的.js文件

In the latter case, bootstrap3_bis2 is not yet integrated on master, so you might consider watching ui-bootstrap repo on github, so you could jump back to master as soon as it gets merged in. 在后一种情况下,bootstrap3_bis2尚未集成在master上,因此您可能会考虑在github上观看ui-bootstrap repo,因此您可以在合并后立即跳回master。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM