How to use bootstrap 4 in angular 2?

后端 未结 11 2586
有刺的猬
有刺的猬 2020-11-30 18:54

I\'m building an angular 2 app written in typescript. It would use the bootstrap 4 framework in combination with some custom theming, is this possible?

The \"ng2-boo

11条回答
  •  感情败类
    2020-11-30 19:34

    Angular v6 Onwards Bootstrap v4 and SCSS

    This works fine with angular 7 scss enabled project

    Run following commands for installing bootstrap, jQuery, and popper.js

    npm install --save bootstrap jquery popper.js
    

    jQuery, and popper.js are prerequisites for running bootstrap4 (refer https://getbootstrap.com for more information.)

    Go to your angular.json file inside root folder. Edit

    architect -> build -> options -> scripts

    node as follows

     "scripts": [
                  "./node_modules/jquery/dist/jquery.slim.min.js",
                  "./node_modules/popper.js/dist/umd/popper.min.js",
                  "./node_modules/bootstrap/dist/js/bootstrap.min.js"
                ]
    

    This will enable javascript functions of bootstrap on your project.

    Than go to src->styles.scss file and add following line

    @import '~bootstrap/scss/bootstrap';
    

提交回复
热议问题