From the root of your project, run in your terminal:
2. And you need to install it's dependencies (jQuery) and (Popper):
npm install jquery@1.9.1 --save
npm install popper.js@^1.12.3 --save
If you want to use SASS rather than CSS use:
npm install bootstrap@4.0.0-beta.2 --save --style=sass
Or if you want to only install for development purposes, just append --save-dev.
npm install bootstrap@4.0.0-beta.2 --save-dev, and make sure you do the same with jQuery and Popper.
3. Open up your angular-cli.json file and add the style and scripts:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
If you're using SASS use this config:
"styles": [
"styles.scss"
],
"scripts": [
"../node_modules/jquery/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
And with SASS you need to make one last step. Place the line below in your styles.scss file (imports bootstrap)
@import "../node_modules/bootstrap/scss/bootstrap"
4. Restart your server and you should be ready to code!
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
"styles": [
"styles.scss"
],
"scripts": [
"../node_modules/jquery/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
@import "../node_modules/bootstrap/scss/bootstrap"
Extra Sass file configuration:
Create directory in: src/styles
Create files and place in that directory: _variables.scss, _custom.scss
Change: .angular-cli.json
"styles": [
"styles/styles.sass"
],
Import files into: styles.scss
@import "../../node_modules/bootstrap/scss/bootstrap"
@import "variables"
@import "custom"
"styles": [
"styles/styles.sass"
],
@import "../../node_modules/bootstrap/scss/bootstrap"
@import "variables"
@import "custom"
Comments
Post a Comment