How to use bootstrap 4 in angular 2?











up vote
43
down vote

favorite
30












I'm building an angular 2 app written in typescript. It would use the bootstrap 4 framework in combination with some custom theming, is this possible?



The "ng2-bootstrap" npm package is not working as it doesn't allow me to use the bootstrap css classes, instead it provides custom components. (http://github.com/valor-software/ng2-bootstrap)



In my angular 2 project I'm using sass, would it be possible to build bootstrap 4 from source as it is also using sass for styling?










share|improve this question






















  • you can use it normal way. I'm not sure about your sass. ng2-bootstrap only provides you components.
    – micronyks
    Jul 22 '16 at 20:04















up vote
43
down vote

favorite
30












I'm building an angular 2 app written in typescript. It would use the bootstrap 4 framework in combination with some custom theming, is this possible?



The "ng2-bootstrap" npm package is not working as it doesn't allow me to use the bootstrap css classes, instead it provides custom components. (http://github.com/valor-software/ng2-bootstrap)



In my angular 2 project I'm using sass, would it be possible to build bootstrap 4 from source as it is also using sass for styling?










share|improve this question






















  • you can use it normal way. I'm not sure about your sass. ng2-bootstrap only provides you components.
    – micronyks
    Jul 22 '16 at 20:04













up vote
43
down vote

favorite
30









up vote
43
down vote

favorite
30






30





I'm building an angular 2 app written in typescript. It would use the bootstrap 4 framework in combination with some custom theming, is this possible?



The "ng2-bootstrap" npm package is not working as it doesn't allow me to use the bootstrap css classes, instead it provides custom components. (http://github.com/valor-software/ng2-bootstrap)



In my angular 2 project I'm using sass, would it be possible to build bootstrap 4 from source as it is also using sass for styling?










share|improve this question













I'm building an angular 2 app written in typescript. It would use the bootstrap 4 framework in combination with some custom theming, is this possible?



The "ng2-bootstrap" npm package is not working as it doesn't allow me to use the bootstrap css classes, instead it provides custom components. (http://github.com/valor-software/ng2-bootstrap)



In my angular 2 project I'm using sass, would it be possible to build bootstrap 4 from source as it is also using sass for styling?







twitter-bootstrap typescript angular npm sass






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 22 '16 at 19:49









aqwsez

3541512




3541512












  • you can use it normal way. I'm not sure about your sass. ng2-bootstrap only provides you components.
    – micronyks
    Jul 22 '16 at 20:04


















  • you can use it normal way. I'm not sure about your sass. ng2-bootstrap only provides you components.
    – micronyks
    Jul 22 '16 at 20:04
















you can use it normal way. I'm not sure about your sass. ng2-bootstrap only provides you components.
– micronyks
Jul 22 '16 at 20:04




you can use it normal way. I'm not sure about your sass. ng2-bootstrap only provides you components.
– micronyks
Jul 22 '16 at 20:04












10 Answers
10






active

oldest

votes

















up vote
8
down vote



accepted










To use any visual library that needs JQuery just do the following:




  • Add the library css in the index;

  • Add the jquery js file to index;

  • Add the library js files in the index;

  • Install the library definition files (d.ts);

  • Install jquery definitions files (d.ts);


If the library doesn't have definition files you could:




  • Create the definition yourself;

  • Create a global any variable with the same name of the library object, just to not get compiler errors;

  • Use with errors (this is the worst option);


Now you can use the library inside Typescript;






share|improve this answer






























    up vote
    92
    down vote













    Bootstrap4 alpha for Angular2 CLI (also works for Angular4 CLI)



    If you are using the angular2 cli/angular 4 cli do following:



    npm i bootstrap@next --save


    This will add bootstrap 4 to your project.



    Next go to your src/style.scss or src/style.css file and import bootstrap there:



    For style.css



    /* You can add global styles to this file, and also import other style files */
    @import "../node_modules/bootstrap/dist/css/bootstrap.min.css";


    For style.scss



    /* You can add global styles to this file, and also import other style files */
    @import "../node_modules/bootstrap/scss/bootstrap";


    If you are using scss, make sure you change your default styling to scss in .angular-cli.json:



      "defaults": {
    "styleExt": "scss",
    "component": {}
    }


    Bootstrap JS Components



    For Bootstrap JS components to work you will still need to import bootstrap.js into .angular-cli.json under scripts (this should happen automatically):



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


    Update 2017/09/13: Boostrap 4 Beta is now using popper.js instead of tether.js. So depending on which version you are using import either tether.js (alpha) or popper.js (beta) in your scripts. Thanks for the heads up @MinorThreat






    share|improve this answer























    • This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
      – Matt Sugden
      Mar 8 '17 at 21:50










    • @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
      – mahatmanich
      Mar 9 '17 at 9:51










    • @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
      – mahatmanich
      Mar 9 '17 at 9:53






    • 2




      You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
      – Matt Sugden
      Mar 9 '17 at 15:25






    • 2




      I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
      – Minor Threat
      Aug 30 '17 at 1:22


















    up vote
    38
    down vote













    The options above will work, however I use this approach via NPM:




    1. Navigate to: Bootstrap 4 and retrieve the npm command


    2. Run the NPM command obtained from step 1 in your project i.e



      npm install bootstrap@4.0.0-alpha.5 --save



    3. After installing the above dependency run the following npm command which will install the bootstrap module
      npm install --save @ng-bootstrap/ng-bootstrap
      You can read more about this here


    4. Add the following import into app.module import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; and add NgbModule to the imports


    5. Your app module will look like this:



      import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

      @NgModule({
      declarations: [
      AppComponent,
      WeatherComponent
      ],
      imports: [
      BrowserModule,
      FormsModule,
      HttpModule,
      NgbModule.forRoot(), // Add Bootstrap module here.
      ],
      providers: ,
      bootstrap: [AppComponent]
      })

      export class AppModule { }



    6. Open angular-cli.json and insert a new entry into the styles array :



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



    7. Open src/app/app.component.html and add



      <alert type="success">hello</alert>


      or if you would like to use ng alert then place the following on your app.component.html page



      <ngb-alert [dismissible]="true">I'm a dismissible alert :) </ngb-alert>


    8. Now run your project and you should see the bootstrap alert message in the browser.



    NOTE: You can read more about ng Components here






    share|improve this answer



















    • 1




      I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
      – Alan Hay
      Jan 22 '17 at 15:19










    • @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
      – Code Ratchet
      Jan 23 '17 at 5:50










    • Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
      – Code Ratchet
      Jan 23 '17 at 5:52






    • 1




      I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
      – Devner
      Jan 28 '17 at 18:13










    • Interesting, you'll need to use the typescript component code which is used in the example.
      – Code Ratchet
      Jan 29 '17 at 22:30


















    up vote
    7
    down vote













    I would suggest:




    • Simply including a link to the Bootstrap's CSS file in your index.html page

    • Using ng-bootstrap - a dedicated set of Angular 2 directives for parts where dynamic behaviour is needed. This way you don't need to import / setup jQuery nor care about Bootstrap's JavaScript.






    share|improve this answer




























      up vote
      2
      down vote













      You can use npm for installing the latest bootstrap version. This can be done using the command:



      npm install bootstrap@4.0.0-beta


      And after this you might have to import bootstrap.css into your main css file. Which will be styles.css, if you are using angular-cli.



      @import '~bootstrap/dist/css/bootstrap.min.css';


      If you want to know more please use the link: http://technobytz.com/install-bootstrap-4-using-npm.html






      share|improve this answer




























        up vote
        1
        down vote













        First goto your project directory and follow the below given steps.



        1) npm install --save @ng-bootstrap/ng-bootstrap (run this command in node js command prompt)



        2)npm install bootstrap@4.0.0-alpha.6 (next run this)



        3)import {NgbModule} from '@ng-bootstrap/ng-bootstrap'(write this in app module.ts)



        4) If Module is your root module include this



        `@NgModule({
        declarations: [AppComponent, ...],
        imports: [NgbModule.forRoot(), ...],
        bootstrap: [AppComponent]
        })`

        (or)


        If not root Module



        `@NgModule({
        declarations: [OtherComponent, ...],
        imports: [NgbModule, ...]
        })`


        5) Write this in system.config.js



        `map: {
        '@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-
        bootstrap/bundles/ng-bootstrap.js',
        }`


        6) Add in Index.html



        `<script src="../node_modules/jquery/dist/jquery.min.js"></script>
        <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
        <link rel="stylesheet" type="text/css"
        href="../node_modules/bootstrap/dist/css/bootstrap.min.css" />`





        share|improve this answer























        • Shouldn't the bootstrap 4 itself contain --save?
          – Randy
          Jun 29 '17 at 13:16


















        up vote
        0
        down vote













        ng add has been introduced with Angular 6. To install Bootstrap 4 (ng-bootstrap 2.0.0)



        ng add @ng-bootstrap/schematics


        Don't forget to restart your app with ng serve.






        share|improve this answer




























          up vote
          0
          down vote













          In angular 6 dont use npm i bootstrap@next --save may it would work but sometimes it would not better to add these:



          <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

          <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

          <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>





          share|improve this answer























          • You've linked cdn's for bootstrap v3...
            – ChrisEenberg
            Oct 5 at 11:35












          • @ChrisEenberg now its ok??
            – nikhil sugandh
            Oct 5 at 11:56










          • yes, Perfect :)
            – ChrisEenberg
            Oct 5 at 12:59










          • @ChrisEenberg now give it an upvote
            – nikhil sugandh
            Oct 5 at 13:40


















          up vote
          0
          down vote













          In angular 6: First install bootstrap in project directory npm install bootstrap. If you look at the Angular.JSON file you will see that styles.css is already referenced so in styles.css just add @import "~bootstrap/dist/css/bootstrap.css";






          share|improve this answer




























            up vote
            0
            down vote














            Angular v6 Onwards Bootstrap v4 and SCSS




            This works fine with angular 7 scss enabled project



            Run following commands for installing bootstrap, jQuery, and popper.js



            npm install --save bootstrap jquery popper.js


            jQuery, and popper.js are prerequisites for running bootstrap4 (refer https://getbootstrap.com for more information.)



            Go to your angular.json file inside root folder. Edit




            architect -> build -> options -> scripts




            node as follows



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


            This will enable javascript functions of bootstrap on your project.



            Than go to src->styles.scss file and add following line



            @import '~bootstrap/scss/bootstrap';





            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38534276%2fhow-to-use-bootstrap-4-in-angular-2%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              10 Answers
              10






              active

              oldest

              votes








              10 Answers
              10






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              8
              down vote



              accepted










              To use any visual library that needs JQuery just do the following:




              • Add the library css in the index;

              • Add the jquery js file to index;

              • Add the library js files in the index;

              • Install the library definition files (d.ts);

              • Install jquery definitions files (d.ts);


              If the library doesn't have definition files you could:




              • Create the definition yourself;

              • Create a global any variable with the same name of the library object, just to not get compiler errors;

              • Use with errors (this is the worst option);


              Now you can use the library inside Typescript;






              share|improve this answer



























                up vote
                8
                down vote



                accepted










                To use any visual library that needs JQuery just do the following:




                • Add the library css in the index;

                • Add the jquery js file to index;

                • Add the library js files in the index;

                • Install the library definition files (d.ts);

                • Install jquery definitions files (d.ts);


                If the library doesn't have definition files you could:




                • Create the definition yourself;

                • Create a global any variable with the same name of the library object, just to not get compiler errors;

                • Use with errors (this is the worst option);


                Now you can use the library inside Typescript;






                share|improve this answer

























                  up vote
                  8
                  down vote



                  accepted







                  up vote
                  8
                  down vote



                  accepted






                  To use any visual library that needs JQuery just do the following:




                  • Add the library css in the index;

                  • Add the jquery js file to index;

                  • Add the library js files in the index;

                  • Install the library definition files (d.ts);

                  • Install jquery definitions files (d.ts);


                  If the library doesn't have definition files you could:




                  • Create the definition yourself;

                  • Create a global any variable with the same name of the library object, just to not get compiler errors;

                  • Use with errors (this is the worst option);


                  Now you can use the library inside Typescript;






                  share|improve this answer














                  To use any visual library that needs JQuery just do the following:




                  • Add the library css in the index;

                  • Add the jquery js file to index;

                  • Add the library js files in the index;

                  • Install the library definition files (d.ts);

                  • Install jquery definitions files (d.ts);


                  If the library doesn't have definition files you could:




                  • Create the definition yourself;

                  • Create a global any variable with the same name of the library object, just to not get compiler errors;

                  • Use with errors (this is the worst option);


                  Now you can use the library inside Typescript;







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 4 '16 at 14:04

























                  answered Jul 22 '16 at 20:07









                  Reginaldo Camargo Ribeiro

                  622214




                  622214
























                      up vote
                      92
                      down vote













                      Bootstrap4 alpha for Angular2 CLI (also works for Angular4 CLI)



                      If you are using the angular2 cli/angular 4 cli do following:



                      npm i bootstrap@next --save


                      This will add bootstrap 4 to your project.



                      Next go to your src/style.scss or src/style.css file and import bootstrap there:



                      For style.css



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/dist/css/bootstrap.min.css";


                      For style.scss



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/scss/bootstrap";


                      If you are using scss, make sure you change your default styling to scss in .angular-cli.json:



                        "defaults": {
                      "styleExt": "scss",
                      "component": {}
                      }


                      Bootstrap JS Components



                      For Bootstrap JS components to work you will still need to import bootstrap.js into .angular-cli.json under scripts (this should happen automatically):



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


                      Update 2017/09/13: Boostrap 4 Beta is now using popper.js instead of tether.js. So depending on which version you are using import either tether.js (alpha) or popper.js (beta) in your scripts. Thanks for the heads up @MinorThreat






                      share|improve this answer























                      • This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
                        – Matt Sugden
                        Mar 8 '17 at 21:50










                      • @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
                        – mahatmanich
                        Mar 9 '17 at 9:51










                      • @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
                        – mahatmanich
                        Mar 9 '17 at 9:53






                      • 2




                        You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
                        – Matt Sugden
                        Mar 9 '17 at 15:25






                      • 2




                        I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
                        – Minor Threat
                        Aug 30 '17 at 1:22















                      up vote
                      92
                      down vote













                      Bootstrap4 alpha for Angular2 CLI (also works for Angular4 CLI)



                      If you are using the angular2 cli/angular 4 cli do following:



                      npm i bootstrap@next --save


                      This will add bootstrap 4 to your project.



                      Next go to your src/style.scss or src/style.css file and import bootstrap there:



                      For style.css



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/dist/css/bootstrap.min.css";


                      For style.scss



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/scss/bootstrap";


                      If you are using scss, make sure you change your default styling to scss in .angular-cli.json:



                        "defaults": {
                      "styleExt": "scss",
                      "component": {}
                      }


                      Bootstrap JS Components



                      For Bootstrap JS components to work you will still need to import bootstrap.js into .angular-cli.json under scripts (this should happen automatically):



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


                      Update 2017/09/13: Boostrap 4 Beta is now using popper.js instead of tether.js. So depending on which version you are using import either tether.js (alpha) or popper.js (beta) in your scripts. Thanks for the heads up @MinorThreat






                      share|improve this answer























                      • This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
                        – Matt Sugden
                        Mar 8 '17 at 21:50










                      • @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
                        – mahatmanich
                        Mar 9 '17 at 9:51










                      • @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
                        – mahatmanich
                        Mar 9 '17 at 9:53






                      • 2




                        You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
                        – Matt Sugden
                        Mar 9 '17 at 15:25






                      • 2




                        I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
                        – Minor Threat
                        Aug 30 '17 at 1:22













                      up vote
                      92
                      down vote










                      up vote
                      92
                      down vote









                      Bootstrap4 alpha for Angular2 CLI (also works for Angular4 CLI)



                      If you are using the angular2 cli/angular 4 cli do following:



                      npm i bootstrap@next --save


                      This will add bootstrap 4 to your project.



                      Next go to your src/style.scss or src/style.css file and import bootstrap there:



                      For style.css



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/dist/css/bootstrap.min.css";


                      For style.scss



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/scss/bootstrap";


                      If you are using scss, make sure you change your default styling to scss in .angular-cli.json:



                        "defaults": {
                      "styleExt": "scss",
                      "component": {}
                      }


                      Bootstrap JS Components



                      For Bootstrap JS components to work you will still need to import bootstrap.js into .angular-cli.json under scripts (this should happen automatically):



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


                      Update 2017/09/13: Boostrap 4 Beta is now using popper.js instead of tether.js. So depending on which version you are using import either tether.js (alpha) or popper.js (beta) in your scripts. Thanks for the heads up @MinorThreat






                      share|improve this answer














                      Bootstrap4 alpha for Angular2 CLI (also works for Angular4 CLI)



                      If you are using the angular2 cli/angular 4 cli do following:



                      npm i bootstrap@next --save


                      This will add bootstrap 4 to your project.



                      Next go to your src/style.scss or src/style.css file and import bootstrap there:



                      For style.css



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/dist/css/bootstrap.min.css";


                      For style.scss



                      /* You can add global styles to this file, and also import other style files */
                      @import "../node_modules/bootstrap/scss/bootstrap";


                      If you are using scss, make sure you change your default styling to scss in .angular-cli.json:



                        "defaults": {
                      "styleExt": "scss",
                      "component": {}
                      }


                      Bootstrap JS Components



                      For Bootstrap JS components to work you will still need to import bootstrap.js into .angular-cli.json under scripts (this should happen automatically):



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


                      Update 2017/09/13: Boostrap 4 Beta is now using popper.js instead of tether.js. So depending on which version you are using import either tether.js (alpha) or popper.js (beta) in your scripts. Thanks for the heads up @MinorThreat







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Sep 13 '17 at 9:05

























                      answered Oct 7 '16 at 9:42









                      mahatmanich

                      6,37324463




                      6,37324463












                      • This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
                        – Matt Sugden
                        Mar 8 '17 at 21:50










                      • @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
                        – mahatmanich
                        Mar 9 '17 at 9:51










                      • @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
                        – mahatmanich
                        Mar 9 '17 at 9:53






                      • 2




                        You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
                        – Matt Sugden
                        Mar 9 '17 at 15:25






                      • 2




                        I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
                        – Minor Threat
                        Aug 30 '17 at 1:22


















                      • This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
                        – Matt Sugden
                        Mar 8 '17 at 21:50










                      • @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
                        – mahatmanich
                        Mar 9 '17 at 9:51










                      • @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
                        – mahatmanich
                        Mar 9 '17 at 9:53






                      • 2




                        You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
                        – Matt Sugden
                        Mar 9 '17 at 15:25






                      • 2




                        I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
                        – Minor Threat
                        Aug 30 '17 at 1:22
















                      This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
                      – Matt Sugden
                      Mar 8 '17 at 21:50




                      This worked for me, but I also need to add the import statement to each component that needs it. E.g when I just add it to my styles.scss, my navbar component didn't look right until I also imported it into my navbar.component.scss file. This feels like a bit of an overhead as my application grows, having to import bootstrap into every component style sheet.
                      – Matt Sugden
                      Mar 8 '17 at 21:50












                      @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
                      – mahatmanich
                      Mar 9 '17 at 9:51




                      @MattSugden You should not need to import it into all components. Did you change your default style type to scss? See my updated answer!
                      – mahatmanich
                      Mar 9 '17 at 9:51












                      @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
                      – mahatmanich
                      Mar 9 '17 at 9:53




                      @MattSugden Also note, there was a recent update of bootstrap 4 which changed navigation style significantly. So check if you are using the right html elements and classes. I had similar problems with a project.
                      – mahatmanich
                      Mar 9 '17 at 9:53




                      2




                      2




                      You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
                      – Matt Sugden
                      Mar 9 '17 at 15:25




                      You're absolutely right, it was my mistake, I was adding it to app.component.scss, not styles.scss. It was late & I'd been looking at it for too long!
                      – Matt Sugden
                      Mar 9 '17 at 15:25




                      2




                      2




                      I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
                      – Minor Threat
                      Aug 30 '17 at 1:22




                      I think this posting should be updated. For example, I've noticed that they dropped tether in favor of popper.
                      – Minor Threat
                      Aug 30 '17 at 1:22










                      up vote
                      38
                      down vote













                      The options above will work, however I use this approach via NPM:




                      1. Navigate to: Bootstrap 4 and retrieve the npm command


                      2. Run the NPM command obtained from step 1 in your project i.e



                        npm install bootstrap@4.0.0-alpha.5 --save



                      3. After installing the above dependency run the following npm command which will install the bootstrap module
                        npm install --save @ng-bootstrap/ng-bootstrap
                        You can read more about this here


                      4. Add the following import into app.module import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; and add NgbModule to the imports


                      5. Your app module will look like this:



                        import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

                        @NgModule({
                        declarations: [
                        AppComponent,
                        WeatherComponent
                        ],
                        imports: [
                        BrowserModule,
                        FormsModule,
                        HttpModule,
                        NgbModule.forRoot(), // Add Bootstrap module here.
                        ],
                        providers: ,
                        bootstrap: [AppComponent]
                        })

                        export class AppModule { }



                      6. Open angular-cli.json and insert a new entry into the styles array :



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



                      7. Open src/app/app.component.html and add



                        <alert type="success">hello</alert>


                        or if you would like to use ng alert then place the following on your app.component.html page



                        <ngb-alert [dismissible]="true">I'm a dismissible alert :) </ngb-alert>


                      8. Now run your project and you should see the bootstrap alert message in the browser.



                      NOTE: You can read more about ng Components here






                      share|improve this answer



















                      • 1




                        I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
                        – Alan Hay
                        Jan 22 '17 at 15:19










                      • @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
                        – Code Ratchet
                        Jan 23 '17 at 5:50










                      • Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
                        – Code Ratchet
                        Jan 23 '17 at 5:52






                      • 1




                        I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
                        – Devner
                        Jan 28 '17 at 18:13










                      • Interesting, you'll need to use the typescript component code which is used in the example.
                        – Code Ratchet
                        Jan 29 '17 at 22:30















                      up vote
                      38
                      down vote













                      The options above will work, however I use this approach via NPM:




                      1. Navigate to: Bootstrap 4 and retrieve the npm command


                      2. Run the NPM command obtained from step 1 in your project i.e



                        npm install bootstrap@4.0.0-alpha.5 --save



                      3. After installing the above dependency run the following npm command which will install the bootstrap module
                        npm install --save @ng-bootstrap/ng-bootstrap
                        You can read more about this here


                      4. Add the following import into app.module import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; and add NgbModule to the imports


                      5. Your app module will look like this:



                        import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

                        @NgModule({
                        declarations: [
                        AppComponent,
                        WeatherComponent
                        ],
                        imports: [
                        BrowserModule,
                        FormsModule,
                        HttpModule,
                        NgbModule.forRoot(), // Add Bootstrap module here.
                        ],
                        providers: ,
                        bootstrap: [AppComponent]
                        })

                        export class AppModule { }



                      6. Open angular-cli.json and insert a new entry into the styles array :



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



                      7. Open src/app/app.component.html and add



                        <alert type="success">hello</alert>


                        or if you would like to use ng alert then place the following on your app.component.html page



                        <ngb-alert [dismissible]="true">I'm a dismissible alert :) </ngb-alert>


                      8. Now run your project and you should see the bootstrap alert message in the browser.



                      NOTE: You can read more about ng Components here






                      share|improve this answer



















                      • 1




                        I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
                        – Alan Hay
                        Jan 22 '17 at 15:19










                      • @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
                        – Code Ratchet
                        Jan 23 '17 at 5:50










                      • Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
                        – Code Ratchet
                        Jan 23 '17 at 5:52






                      • 1




                        I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
                        – Devner
                        Jan 28 '17 at 18:13










                      • Interesting, you'll need to use the typescript component code which is used in the example.
                        – Code Ratchet
                        Jan 29 '17 at 22:30













                      up vote
                      38
                      down vote










                      up vote
                      38
                      down vote









                      The options above will work, however I use this approach via NPM:




                      1. Navigate to: Bootstrap 4 and retrieve the npm command


                      2. Run the NPM command obtained from step 1 in your project i.e



                        npm install bootstrap@4.0.0-alpha.5 --save



                      3. After installing the above dependency run the following npm command which will install the bootstrap module
                        npm install --save @ng-bootstrap/ng-bootstrap
                        You can read more about this here


                      4. Add the following import into app.module import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; and add NgbModule to the imports


                      5. Your app module will look like this:



                        import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

                        @NgModule({
                        declarations: [
                        AppComponent,
                        WeatherComponent
                        ],
                        imports: [
                        BrowserModule,
                        FormsModule,
                        HttpModule,
                        NgbModule.forRoot(), // Add Bootstrap module here.
                        ],
                        providers: ,
                        bootstrap: [AppComponent]
                        })

                        export class AppModule { }



                      6. Open angular-cli.json and insert a new entry into the styles array :



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



                      7. Open src/app/app.component.html and add



                        <alert type="success">hello</alert>


                        or if you would like to use ng alert then place the following on your app.component.html page



                        <ngb-alert [dismissible]="true">I'm a dismissible alert :) </ngb-alert>


                      8. Now run your project and you should see the bootstrap alert message in the browser.



                      NOTE: You can read more about ng Components here






                      share|improve this answer














                      The options above will work, however I use this approach via NPM:




                      1. Navigate to: Bootstrap 4 and retrieve the npm command


                      2. Run the NPM command obtained from step 1 in your project i.e



                        npm install bootstrap@4.0.0-alpha.5 --save



                      3. After installing the above dependency run the following npm command which will install the bootstrap module
                        npm install --save @ng-bootstrap/ng-bootstrap
                        You can read more about this here


                      4. Add the following import into app.module import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; and add NgbModule to the imports


                      5. Your app module will look like this:



                        import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

                        @NgModule({
                        declarations: [
                        AppComponent,
                        WeatherComponent
                        ],
                        imports: [
                        BrowserModule,
                        FormsModule,
                        HttpModule,
                        NgbModule.forRoot(), // Add Bootstrap module here.
                        ],
                        providers: ,
                        bootstrap: [AppComponent]
                        })

                        export class AppModule { }



                      6. Open angular-cli.json and insert a new entry into the styles array :



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



                      7. Open src/app/app.component.html and add



                        <alert type="success">hello</alert>


                        or if you would like to use ng alert then place the following on your app.component.html page



                        <ngb-alert [dismissible]="true">I'm a dismissible alert :) </ngb-alert>


                      8. Now run your project and you should see the bootstrap alert message in the browser.



                      NOTE: You can read more about ng Components here







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited May 12 '17 at 19:15









                      George Kagan

                      3,36253548




                      3,36253548










                      answered Dec 20 '16 at 4:13









                      Code Ratchet

                      2,19984893




                      2,19984893








                      • 1




                        I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
                        – Alan Hay
                        Jan 22 '17 at 15:19










                      • @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
                        – Code Ratchet
                        Jan 23 '17 at 5:50










                      • Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
                        – Code Ratchet
                        Jan 23 '17 at 5:52






                      • 1




                        I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
                        – Devner
                        Jan 28 '17 at 18:13










                      • Interesting, you'll need to use the typescript component code which is used in the example.
                        – Code Ratchet
                        Jan 29 '17 at 22:30














                      • 1




                        I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
                        – Alan Hay
                        Jan 22 '17 at 15:19










                      • @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
                        – Code Ratchet
                        Jan 23 '17 at 5:50










                      • Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
                        – Code Ratchet
                        Jan 23 '17 at 5:52






                      • 1




                        I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
                        – Devner
                        Jan 28 '17 at 18:13










                      • Interesting, you'll need to use the typescript component code which is used in the example.
                        – Code Ratchet
                        Jan 29 '17 at 22:30








                      1




                      1




                      I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
                      – Alan Hay
                      Jan 22 '17 at 15:19




                      I could only get this to work by adding the import NgbModule.forRoot() (in line with the getting started guide) and using the tag <ngb-alert type="success" >hello</ngb-alert>. This displays the alert (although I cannot close it).
                      – Alan Hay
                      Jan 22 '17 at 15:19












                      @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
                      – Code Ratchet
                      Jan 23 '17 at 5:50




                      @AlanHay have you looked at ng-bootstrap.github.io/#/components/alert - Closeable Alert ?
                      – Code Ratchet
                      Jan 23 '17 at 5:50












                      Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
                      – Code Ratchet
                      Jan 23 '17 at 5:52




                      Try this: <ngb-alert [dismissible]="true"> <strong>Warning!</strong> Better check yourself, you're not looking too good. </ngb-alert>
                      – Code Ratchet
                      Jan 23 '17 at 5:52




                      1




                      1




                      I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
                      – Devner
                      Jan 28 '17 at 18:13




                      I confirm that even adding [dismissible]="true" is not helping dismiss the alert. No matter how many times the X icon is clicked, the alert is not dismissed. There are no errors logged in console either.
                      – Devner
                      Jan 28 '17 at 18:13












                      Interesting, you'll need to use the typescript component code which is used in the example.
                      – Code Ratchet
                      Jan 29 '17 at 22:30




                      Interesting, you'll need to use the typescript component code which is used in the example.
                      – Code Ratchet
                      Jan 29 '17 at 22:30










                      up vote
                      7
                      down vote













                      I would suggest:




                      • Simply including a link to the Bootstrap's CSS file in your index.html page

                      • Using ng-bootstrap - a dedicated set of Angular 2 directives for parts where dynamic behaviour is needed. This way you don't need to import / setup jQuery nor care about Bootstrap's JavaScript.






                      share|improve this answer

























                        up vote
                        7
                        down vote













                        I would suggest:




                        • Simply including a link to the Bootstrap's CSS file in your index.html page

                        • Using ng-bootstrap - a dedicated set of Angular 2 directives for parts where dynamic behaviour is needed. This way you don't need to import / setup jQuery nor care about Bootstrap's JavaScript.






                        share|improve this answer























                          up vote
                          7
                          down vote










                          up vote
                          7
                          down vote









                          I would suggest:




                          • Simply including a link to the Bootstrap's CSS file in your index.html page

                          • Using ng-bootstrap - a dedicated set of Angular 2 directives for parts where dynamic behaviour is needed. This way you don't need to import / setup jQuery nor care about Bootstrap's JavaScript.






                          share|improve this answer












                          I would suggest:




                          • Simply including a link to the Bootstrap's CSS file in your index.html page

                          • Using ng-bootstrap - a dedicated set of Angular 2 directives for parts where dynamic behaviour is needed. This way you don't need to import / setup jQuery nor care about Bootstrap's JavaScript.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 23 '16 at 12:05









                          pkozlowski.opensource

                          112k45289258




                          112k45289258






















                              up vote
                              2
                              down vote













                              You can use npm for installing the latest bootstrap version. This can be done using the command:



                              npm install bootstrap@4.0.0-beta


                              And after this you might have to import bootstrap.css into your main css file. Which will be styles.css, if you are using angular-cli.



                              @import '~bootstrap/dist/css/bootstrap.min.css';


                              If you want to know more please use the link: http://technobytz.com/install-bootstrap-4-using-npm.html






                              share|improve this answer

























                                up vote
                                2
                                down vote













                                You can use npm for installing the latest bootstrap version. This can be done using the command:



                                npm install bootstrap@4.0.0-beta


                                And after this you might have to import bootstrap.css into your main css file. Which will be styles.css, if you are using angular-cli.



                                @import '~bootstrap/dist/css/bootstrap.min.css';


                                If you want to know more please use the link: http://technobytz.com/install-bootstrap-4-using-npm.html






                                share|improve this answer























                                  up vote
                                  2
                                  down vote










                                  up vote
                                  2
                                  down vote









                                  You can use npm for installing the latest bootstrap version. This can be done using the command:



                                  npm install bootstrap@4.0.0-beta


                                  And after this you might have to import bootstrap.css into your main css file. Which will be styles.css, if you are using angular-cli.



                                  @import '~bootstrap/dist/css/bootstrap.min.css';


                                  If you want to know more please use the link: http://technobytz.com/install-bootstrap-4-using-npm.html






                                  share|improve this answer












                                  You can use npm for installing the latest bootstrap version. This can be done using the command:



                                  npm install bootstrap@4.0.0-beta


                                  And after this you might have to import bootstrap.css into your main css file. Which will be styles.css, if you are using angular-cli.



                                  @import '~bootstrap/dist/css/bootstrap.min.css';


                                  If you want to know more please use the link: http://technobytz.com/install-bootstrap-4-using-npm.html







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Sep 14 '17 at 1:54









                                  Aravind

                                  1,7631718




                                  1,7631718






















                                      up vote
                                      1
                                      down vote













                                      First goto your project directory and follow the below given steps.



                                      1) npm install --save @ng-bootstrap/ng-bootstrap (run this command in node js command prompt)



                                      2)npm install bootstrap@4.0.0-alpha.6 (next run this)



                                      3)import {NgbModule} from '@ng-bootstrap/ng-bootstrap'(write this in app module.ts)



                                      4) If Module is your root module include this



                                      `@NgModule({
                                      declarations: [AppComponent, ...],
                                      imports: [NgbModule.forRoot(), ...],
                                      bootstrap: [AppComponent]
                                      })`

                                      (or)


                                      If not root Module



                                      `@NgModule({
                                      declarations: [OtherComponent, ...],
                                      imports: [NgbModule, ...]
                                      })`


                                      5) Write this in system.config.js



                                      `map: {
                                      '@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-
                                      bootstrap/bundles/ng-bootstrap.js',
                                      }`


                                      6) Add in Index.html



                                      `<script src="../node_modules/jquery/dist/jquery.min.js"></script>
                                      <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
                                      <link rel="stylesheet" type="text/css"
                                      href="../node_modules/bootstrap/dist/css/bootstrap.min.css" />`





                                      share|improve this answer























                                      • Shouldn't the bootstrap 4 itself contain --save?
                                        – Randy
                                        Jun 29 '17 at 13:16















                                      up vote
                                      1
                                      down vote













                                      First goto your project directory and follow the below given steps.



                                      1) npm install --save @ng-bootstrap/ng-bootstrap (run this command in node js command prompt)



                                      2)npm install bootstrap@4.0.0-alpha.6 (next run this)



                                      3)import {NgbModule} from '@ng-bootstrap/ng-bootstrap'(write this in app module.ts)



                                      4) If Module is your root module include this



                                      `@NgModule({
                                      declarations: [AppComponent, ...],
                                      imports: [NgbModule.forRoot(), ...],
                                      bootstrap: [AppComponent]
                                      })`

                                      (or)


                                      If not root Module



                                      `@NgModule({
                                      declarations: [OtherComponent, ...],
                                      imports: [NgbModule, ...]
                                      })`


                                      5) Write this in system.config.js



                                      `map: {
                                      '@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-
                                      bootstrap/bundles/ng-bootstrap.js',
                                      }`


                                      6) Add in Index.html



                                      `<script src="../node_modules/jquery/dist/jquery.min.js"></script>
                                      <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
                                      <link rel="stylesheet" type="text/css"
                                      href="../node_modules/bootstrap/dist/css/bootstrap.min.css" />`





                                      share|improve this answer























                                      • Shouldn't the bootstrap 4 itself contain --save?
                                        – Randy
                                        Jun 29 '17 at 13:16













                                      up vote
                                      1
                                      down vote










                                      up vote
                                      1
                                      down vote









                                      First goto your project directory and follow the below given steps.



                                      1) npm install --save @ng-bootstrap/ng-bootstrap (run this command in node js command prompt)



                                      2)npm install bootstrap@4.0.0-alpha.6 (next run this)



                                      3)import {NgbModule} from '@ng-bootstrap/ng-bootstrap'(write this in app module.ts)



                                      4) If Module is your root module include this



                                      `@NgModule({
                                      declarations: [AppComponent, ...],
                                      imports: [NgbModule.forRoot(), ...],
                                      bootstrap: [AppComponent]
                                      })`

                                      (or)


                                      If not root Module



                                      `@NgModule({
                                      declarations: [OtherComponent, ...],
                                      imports: [NgbModule, ...]
                                      })`


                                      5) Write this in system.config.js



                                      `map: {
                                      '@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-
                                      bootstrap/bundles/ng-bootstrap.js',
                                      }`


                                      6) Add in Index.html



                                      `<script src="../node_modules/jquery/dist/jquery.min.js"></script>
                                      <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
                                      <link rel="stylesheet" type="text/css"
                                      href="../node_modules/bootstrap/dist/css/bootstrap.min.css" />`





                                      share|improve this answer














                                      First goto your project directory and follow the below given steps.



                                      1) npm install --save @ng-bootstrap/ng-bootstrap (run this command in node js command prompt)



                                      2)npm install bootstrap@4.0.0-alpha.6 (next run this)



                                      3)import {NgbModule} from '@ng-bootstrap/ng-bootstrap'(write this in app module.ts)



                                      4) If Module is your root module include this



                                      `@NgModule({
                                      declarations: [AppComponent, ...],
                                      imports: [NgbModule.forRoot(), ...],
                                      bootstrap: [AppComponent]
                                      })`

                                      (or)


                                      If not root Module



                                      `@NgModule({
                                      declarations: [OtherComponent, ...],
                                      imports: [NgbModule, ...]
                                      })`


                                      5) Write this in system.config.js



                                      `map: {
                                      '@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-
                                      bootstrap/bundles/ng-bootstrap.js',
                                      }`


                                      6) Add in Index.html



                                      `<script src="../node_modules/jquery/dist/jquery.min.js"></script>
                                      <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
                                      <link rel="stylesheet" type="text/css"
                                      href="../node_modules/bootstrap/dist/css/bootstrap.min.css" />`






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Jun 10 '17 at 16:49

























                                      answered Jun 10 '17 at 16:40









                                      Rajesh Chenumalla

                                      193




                                      193












                                      • Shouldn't the bootstrap 4 itself contain --save?
                                        – Randy
                                        Jun 29 '17 at 13:16


















                                      • Shouldn't the bootstrap 4 itself contain --save?
                                        – Randy
                                        Jun 29 '17 at 13:16
















                                      Shouldn't the bootstrap 4 itself contain --save?
                                      – Randy
                                      Jun 29 '17 at 13:16




                                      Shouldn't the bootstrap 4 itself contain --save?
                                      – Randy
                                      Jun 29 '17 at 13:16










                                      up vote
                                      0
                                      down vote













                                      ng add has been introduced with Angular 6. To install Bootstrap 4 (ng-bootstrap 2.0.0)



                                      ng add @ng-bootstrap/schematics


                                      Don't forget to restart your app with ng serve.






                                      share|improve this answer

























                                        up vote
                                        0
                                        down vote













                                        ng add has been introduced with Angular 6. To install Bootstrap 4 (ng-bootstrap 2.0.0)



                                        ng add @ng-bootstrap/schematics


                                        Don't forget to restart your app with ng serve.






                                        share|improve this answer























                                          up vote
                                          0
                                          down vote










                                          up vote
                                          0
                                          down vote









                                          ng add has been introduced with Angular 6. To install Bootstrap 4 (ng-bootstrap 2.0.0)



                                          ng add @ng-bootstrap/schematics


                                          Don't forget to restart your app with ng serve.






                                          share|improve this answer












                                          ng add has been introduced with Angular 6. To install Bootstrap 4 (ng-bootstrap 2.0.0)



                                          ng add @ng-bootstrap/schematics


                                          Don't forget to restart your app with ng serve.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Jun 6 at 8:21









                                          kostjakon

                                          414




                                          414






















                                              up vote
                                              0
                                              down vote













                                              In angular 6 dont use npm i bootstrap@next --save may it would work but sometimes it would not better to add these:



                                              <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>





                                              share|improve this answer























                                              • You've linked cdn's for bootstrap v3...
                                                – ChrisEenberg
                                                Oct 5 at 11:35












                                              • @ChrisEenberg now its ok??
                                                – nikhil sugandh
                                                Oct 5 at 11:56










                                              • yes, Perfect :)
                                                – ChrisEenberg
                                                Oct 5 at 12:59










                                              • @ChrisEenberg now give it an upvote
                                                – nikhil sugandh
                                                Oct 5 at 13:40















                                              up vote
                                              0
                                              down vote













                                              In angular 6 dont use npm i bootstrap@next --save may it would work but sometimes it would not better to add these:



                                              <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>





                                              share|improve this answer























                                              • You've linked cdn's for bootstrap v3...
                                                – ChrisEenberg
                                                Oct 5 at 11:35












                                              • @ChrisEenberg now its ok??
                                                – nikhil sugandh
                                                Oct 5 at 11:56










                                              • yes, Perfect :)
                                                – ChrisEenberg
                                                Oct 5 at 12:59










                                              • @ChrisEenberg now give it an upvote
                                                – nikhil sugandh
                                                Oct 5 at 13:40













                                              up vote
                                              0
                                              down vote










                                              up vote
                                              0
                                              down vote









                                              In angular 6 dont use npm i bootstrap@next --save may it would work but sometimes it would not better to add these:



                                              <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>





                                              share|improve this answer














                                              In angular 6 dont use npm i bootstrap@next --save may it would work but sometimes it would not better to add these:



                                              <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

                                              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>






                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Oct 5 at 11:56

























                                              answered May 24 at 21:15









                                              nikhil sugandh

                                              8201618




                                              8201618












                                              • You've linked cdn's for bootstrap v3...
                                                – ChrisEenberg
                                                Oct 5 at 11:35












                                              • @ChrisEenberg now its ok??
                                                – nikhil sugandh
                                                Oct 5 at 11:56










                                              • yes, Perfect :)
                                                – ChrisEenberg
                                                Oct 5 at 12:59










                                              • @ChrisEenberg now give it an upvote
                                                – nikhil sugandh
                                                Oct 5 at 13:40


















                                              • You've linked cdn's for bootstrap v3...
                                                – ChrisEenberg
                                                Oct 5 at 11:35












                                              • @ChrisEenberg now its ok??
                                                – nikhil sugandh
                                                Oct 5 at 11:56










                                              • yes, Perfect :)
                                                – ChrisEenberg
                                                Oct 5 at 12:59










                                              • @ChrisEenberg now give it an upvote
                                                – nikhil sugandh
                                                Oct 5 at 13:40
















                                              You've linked cdn's for bootstrap v3...
                                              – ChrisEenberg
                                              Oct 5 at 11:35






                                              You've linked cdn's for bootstrap v3...
                                              – ChrisEenberg
                                              Oct 5 at 11:35














                                              @ChrisEenberg now its ok??
                                              – nikhil sugandh
                                              Oct 5 at 11:56




                                              @ChrisEenberg now its ok??
                                              – nikhil sugandh
                                              Oct 5 at 11:56












                                              yes, Perfect :)
                                              – ChrisEenberg
                                              Oct 5 at 12:59




                                              yes, Perfect :)
                                              – ChrisEenberg
                                              Oct 5 at 12:59












                                              @ChrisEenberg now give it an upvote
                                              – nikhil sugandh
                                              Oct 5 at 13:40




                                              @ChrisEenberg now give it an upvote
                                              – nikhil sugandh
                                              Oct 5 at 13:40










                                              up vote
                                              0
                                              down vote













                                              In angular 6: First install bootstrap in project directory npm install bootstrap. If you look at the Angular.JSON file you will see that styles.css is already referenced so in styles.css just add @import "~bootstrap/dist/css/bootstrap.css";






                                              share|improve this answer

























                                                up vote
                                                0
                                                down vote













                                                In angular 6: First install bootstrap in project directory npm install bootstrap. If you look at the Angular.JSON file you will see that styles.css is already referenced so in styles.css just add @import "~bootstrap/dist/css/bootstrap.css";






                                                share|improve this answer























                                                  up vote
                                                  0
                                                  down vote










                                                  up vote
                                                  0
                                                  down vote









                                                  In angular 6: First install bootstrap in project directory npm install bootstrap. If you look at the Angular.JSON file you will see that styles.css is already referenced so in styles.css just add @import "~bootstrap/dist/css/bootstrap.css";






                                                  share|improve this answer












                                                  In angular 6: First install bootstrap in project directory npm install bootstrap. If you look at the Angular.JSON file you will see that styles.css is already referenced so in styles.css just add @import "~bootstrap/dist/css/bootstrap.css";







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Oct 8 at 9:45









                                                  skydev

                                                  171113




                                                  171113






















                                                      up vote
                                                      0
                                                      down vote














                                                      Angular v6 Onwards Bootstrap v4 and SCSS




                                                      This works fine with angular 7 scss enabled project



                                                      Run following commands for installing bootstrap, jQuery, and popper.js



                                                      npm install --save bootstrap jquery popper.js


                                                      jQuery, and popper.js are prerequisites for running bootstrap4 (refer https://getbootstrap.com for more information.)



                                                      Go to your angular.json file inside root folder. Edit




                                                      architect -> build -> options -> scripts




                                                      node as follows



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


                                                      This will enable javascript functions of bootstrap on your project.



                                                      Than go to src->styles.scss file and add following line



                                                      @import '~bootstrap/scss/bootstrap';





                                                      share|improve this answer



























                                                        up vote
                                                        0
                                                        down vote














                                                        Angular v6 Onwards Bootstrap v4 and SCSS




                                                        This works fine with angular 7 scss enabled project



                                                        Run following commands for installing bootstrap, jQuery, and popper.js



                                                        npm install --save bootstrap jquery popper.js


                                                        jQuery, and popper.js are prerequisites for running bootstrap4 (refer https://getbootstrap.com for more information.)



                                                        Go to your angular.json file inside root folder. Edit




                                                        architect -> build -> options -> scripts




                                                        node as follows



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


                                                        This will enable javascript functions of bootstrap on your project.



                                                        Than go to src->styles.scss file and add following line



                                                        @import '~bootstrap/scss/bootstrap';





                                                        share|improve this answer

























                                                          up vote
                                                          0
                                                          down vote










                                                          up vote
                                                          0
                                                          down vote










                                                          Angular v6 Onwards Bootstrap v4 and SCSS




                                                          This works fine with angular 7 scss enabled project



                                                          Run following commands for installing bootstrap, jQuery, and popper.js



                                                          npm install --save bootstrap jquery popper.js


                                                          jQuery, and popper.js are prerequisites for running bootstrap4 (refer https://getbootstrap.com for more information.)



                                                          Go to your angular.json file inside root folder. Edit




                                                          architect -> build -> options -> scripts




                                                          node as follows



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


                                                          This will enable javascript functions of bootstrap on your project.



                                                          Than go to src->styles.scss file and add following line



                                                          @import '~bootstrap/scss/bootstrap';





                                                          share|improve this answer















                                                          Angular v6 Onwards Bootstrap v4 and SCSS




                                                          This works fine with angular 7 scss enabled project



                                                          Run following commands for installing bootstrap, jQuery, and popper.js



                                                          npm install --save bootstrap jquery popper.js


                                                          jQuery, and popper.js are prerequisites for running bootstrap4 (refer https://getbootstrap.com for more information.)



                                                          Go to your angular.json file inside root folder. Edit




                                                          architect -> build -> options -> scripts




                                                          node as follows



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


                                                          This will enable javascript functions of bootstrap on your project.



                                                          Than go to src->styles.scss file and add following line



                                                          @import '~bootstrap/scss/bootstrap';






                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited Nov 13 at 20:21









                                                          marc_s

                                                          567k12810961247




                                                          567k12810961247










                                                          answered Nov 5 at 14:15









                                                          Janith Widarshana

                                                          1,01711933




                                                          1,01711933






























                                                              draft saved

                                                              draft discarded




















































                                                              Thanks for contributing an answer to Stack Overflow!


                                                              • Please be sure to answer the question. Provide details and share your research!

                                                              But avoid



                                                              • Asking for help, clarification, or responding to other answers.

                                                              • Making statements based on opinion; back them up with references or personal experience.


                                                              To learn more, see our tips on writing great answers.





                                                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                              Please pay close attention to the following guidance:


                                                              • Please be sure to answer the question. Provide details and share your research!

                                                              But avoid



                                                              • Asking for help, clarification, or responding to other answers.

                                                              • Making statements based on opinion; back them up with references or personal experience.


                                                              To learn more, see our tips on writing great answers.




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function () {
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38534276%2fhow-to-use-bootstrap-4-in-angular-2%23new-answer', 'question_page');
                                                              }
                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                                                              ComboBox Display Member on multiple fields

                                                              Is it possible to collect Nectar points via Trainline?