我如何在Angular 6 Project中使用bootstrap4弹出窗口和模态

时间:2019-03-26 17:55:06

标签: css angular model bootstrap-4 mean-stack

Angular.json

"styles": [        
      "./node_modules/bootstrap/dist/css/bootstrap.min.css",
                        "./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
                        "src/styles.css"
                    ],
                    "scripts": ["../node_modules/jquery/dist/jquery.js",
                        "../node_modules/tether/dist/js/tether.js",
                        "../node_modules/bootstrap/dist/js/bootstrap.js"
                    ],

我想在我的angular项目中使用bootstrap modal,但是我不能这样做,即使我不把所有模块都放在nangle.json文件中并导入了tham,但是Bootstrap Model却无法正常工作。

Component.html中的模式代码

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
 </button>

<!-- Modal-->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
     <div class="modal-dialog" role="document">
       <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
        </div>
        <div class="modal-body">
            ...
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

我建议使用ng-bootstrap,它们具有Modal。 单击here以获取安装说明。以here为例Modal