Add Bootstrap 4 to Angular 6 or Angular 7 application

前端 未结 5 1539
抹茶落季
抹茶落季 2020-12-20 13:00

I am working on Angular application using bootstrap 4.

I need help related to scss adding in my angular application.

My question is:

5条回答
  •  盖世英雄少女心
    2020-12-20 13:20

    You need to do the following:

    Add Bootstrap to package.json (which is done with npm install bootstrap --save)

    Add Bootstrap to angular.json (jQuery is required too)

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

    Reference Bootstrap in the Angular app (app.module.ts)

    import bootstrap from "bootstrap";
    

    Demo: https://codesandbox.io/s/kmm2q7zvko
    Article: https://medium.com/wdstack/angular-7-bootstrap-4-starter-25573dff23f6

提交回复
热议问题