Skip to content

Instantly share code, notes, and snippets.

@Meligy
Last active August 16, 2016 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Meligy/658e18c3a7a82250de9f7e973186e50b to your computer and use it in GitHub Desktop.
Save Meligy/658e18c3a7a82250de9f7e973186e50b to your computer and use it in GitHub Desktop.
Using ng2-bootstrap with Angular CLI Webpack Version

You can import the different modules wherever you need them.
For example, for a component using AlertComponent, you go to the component you want to use the alert in, and just import it:

import { AlertComponent } from 'ng2-bootstrap/ng2-bootstrap';

After that, you add it to the directives of your @Cimponent.

directives: [AlertComponent]

Then you can just go and use it in the component HTML:

<Alert>Message</Alert>

Note that the bootstrap CSS is not included in ng2-bootstrap. You'll have to load this manually.

If you want to load this locally not from a CDN, you are in for more trouble.

Just doing

import 'bootstrap/dist/css/bootstrap.css';

will not work. There's an open issue about it.

One possible workaround is to include the CSS in AppComponent, and change the view encapsulation to None so the styles are loaded globally for that component:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment