Skip to content

Instantly share code, notes, and snippets.

@killerchip
Created January 1, 2018 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerchip/6adaac2423ec7709cd0b16f5fed387d5 to your computer and use it in GitHub Desktop.
Save killerchip/6adaac2423ec7709cd0b16f5fed387d5 to your computer and use it in GitHub Desktop.
Angular guide: Setup Bootstrap with Angular project

Setup Bootstrap with Angular

The instructions here are based on this blog... https://medium.com/codingthesmartway-com-blog/using-bootstrap-with-angular-c83c3cee3f4a

The method here is using Bootstrap 4 (beta.2) with ng-bootstrap package.

Install ng-bootstrap

npm install --save @ng-bootstrap/ng-bootstrap

Install bootstrap 4

 npm install --save bootstrap@4.0.0-beta-2

Add files to angular-cli.json

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

Import NgbModule Import NgbModule in app.component

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

...

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

(Optionally) Import in other modules If you need to import in other modules, import without the .forRoot() method:

@NgModule({
  declarations: [OtherComponent, ...],
  imports: [NgbModule, ...]
})
export class OtherModule {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment