Sunday, April 14, 2019

Install Bootstrap and JQuery in Angular application

To install bootstrap and jQuery use below command and update the angular.json file to refer this.

npm install bootstrap@3 jquery --save

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


If you want to refer jquery and bootstrap script files you can add in scripts array as below.

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

To test bootstrap working or not just add a bootstrap button in app.component.html as below.

<div style="text-align:center">
  <h1>
    {{ title }}
  </h1>
  <button class="btn btn-primary">
    Bootstrap Styled Button
  </button>
</div>
<router-outlet></router-outlet>

Save the file and run the application using a command prompt.

ng s -o

Will get the below output.




No comments:

Post a Comment