Setting up Bootstrap
Setting up Bootstrap
Using npm:
Bootstrap can be installed as a dependency for the Angular project using npm (Node Package Manager).
This method is preferred for managing dependencies directly within the project.
Using cdnjs:
Bootstrap can be linked via URLs from cdnjs, a free and open-source CDN service.
This method avoids installation but requires an internet connection during development.
To integrate Bootstrap using cdnjs, you need to add the necessary JavaScript and CSS files to your index.html file.
JavaScript:
CSS Files:
bootstrap.min.js https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.min.js
bootstrap.bundle.min.js https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.bundle.min.js
bootstrap.min.css https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css
bootstrap-grid.min.css https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap-grid.min.css
bootstrap- https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap-
reboot.min.css
reboot.min.css
bootstrap- https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap-
utilities.min.css utilities.min.css
<script vbscript-html
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.min.js"
integrity="sha512-1/RvTCDvEU"
crossorigin="anonymous">
</script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css"
integrity="sha512-..."
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap-grid.min.cs
s"
integrity="sha512-..."
crossorigin="anonymous">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap-reboot.min.c
ss"
integrity="sha512-..."
crossorigin="anonymous">
2. Type the following command in the terminal to start the development server:
ng serve bash
Type y (yes), and Angular will assign a different port (e.g., localhost:55375 ).
Refresh the page and look for Bootstrap .js and .css files in the Network log.
2. Checking Styles
Refresh the browser. The button should have Bootstrap's primary button styling (blue background, white text).
3. Add the Bootstrap CSS and JavaScript paths under the "styles" and "scripts" arrays:
"styles": [ json
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]
ng serve bash