Using Bootstrap 4 with Angular 4

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:45:46

问题


After installing Bootstrap 4, in Angular 4, I am getting an error : [Script Loader] Error: Bootstrap tooltips require Tether (http://tether.io/). I tried installing tether, passing tether CDN but it dint help.


回答1:


Add the reference to tether.min.css in your angular-cli.json file

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



回答2:


Watch Video or Follow the step

Install bootstrap 4 in angular 4 / angular 5

There is two way to include bootstrap in your project
1) add CDN Link in index.html file
2) Install bootstrap using npm

I recommended you following 2 methods that are installed bootstrap using npm because its available on your project directory

1) install bootstrap using npm

npm install bootstrap@next --save

after the installation of Bootstrap 4, we Need two More javascript Package that is Jquery and Popper.js without these two package bootstrap is not complete

2) Install JQUERY

npm install jquery --save

3) Install Popper.js

npm install popper.js --save

Now Bootstrap is Install on you Project Directory inside node_modules Folder

open .angular-cli.json this file are available on you angular directory open that file and add the path of bootstrap, jquery, and popper.js files inside styles[] and scripts[] path see the below example

"styles": [   
    "../node_modules/bootstrap/dist/css/bootstrap.min.css",
    "styles.css"
  ],
  "scripts": [  

    "../node_modules/jquery/dist/jquery.min.js",
    "../node_modules/bootstrap/dist/js/bootstrap.min.js",
    "../node_modules/popper.js/dist/umd/popper.min.js"
  ],

Note: Don't change a sequence of js file it should be like this

Now Bootstrap Working fine Now



来源:https://stackoverflow.com/questions/47431612/using-bootstrap-4-with-angular-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!