# ng2-bootstrap [](http://badge.fury.io/js/ng2-bootstrap) [](https://npmjs.org/ng2-bootstrap)
Native Angular2 directives for Bootstrap, works with Bootstrap 3 and 4-alfa
Follow me [](https://twitter.com/valorkin) to be notified about new releases.
[](https://angular.io/styleguide)
[](https://travis-ci.org/valor-software/ng2-bootstrap)
[](https://codecov.io/gh/valor-software/ng2-bootstrap)
[](https://www.hamsterpad.com/chat/ng2)
[](https://gitter.im/valor-software/ng2-bootstrap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://david-dm.org/valor-software/ng2-bootstrap)
[](https://nodei.co/npm/anymatch/)
[](https://nodei.co/npm-dl/anymatch/)
[](https://waffle.io/valor-software/ng2-bootstrap/metrics)
# Usage & Demo
[http://valor-software.github.io/ng2-bootstrap/](http://valor-software.github.io/ng2-bootstrap/)
## If you need more modules check [here](https://github.com/valor-software/ng2-plans)
# Starter packages
*Hint*: simpliest way to add styles is a CDN:
```html
```
### With system.js: [angular2-quickstart](https://github.com/valor-software/angular2-quickstart)
### With webpack: [AngularClass/angular2-webpack-starter](https://github.com/AngularClass/angular2-webpack-starter)
- install `ng2-bootstrap` and typings for `moment.js`
```bash
npm install ng2-bootstrap --save
# Install typings from NPM. Ambient typings will not help
typings install moment --save
```
- add some code
```html
Hello from ng2-bootstrap {{ date.toDateString() }}
```
```js
/* src/app/main.ts */
import { AlertModule, DatepickerModule } from 'ng2-bootstrap/ng2-bootstrap';
...
@NgModule({
imports: [
...
AlertModule,
DatepickerModule
]
...
})
export class AppModule {
}
/* src/app/home/home.ts */
...
@Component({
templateUrl: 'src/app/home/home.html'
})
export class Home {
date: Date = new Date();
}
```
### With gulp and system.js: [pkozlowski-opensource/ng2-play](https://github.com/pkozlowski-opensource/ng2-play) or [mgechev/angular2-seed](https://github.com/mgechev/angular2-seed)
- *hint*: see `quickstart` section below for samples
- just add link to `ng2-bootstrap` `system.js` bundle to `index.html` like in [angular2-quickstart](https://github.com/valor-software/angular2-quickstart)
- and `moment.js` map in `system.js` configuration
## Install from npm
```bash
npm i ng2-bootstrap --save
```
## Install from CDN
Check [cdnjs](https://cdnjs.com/libraries/ng2-bootstrap) to include `ng2-bootstrap` as `system.js` bundle
```html
```
## Quick start
*Hint*: you can just clone [angular2-quickstart](https://github.com/valor-software/angular2-quickstart)
If you are following [Angular2 5 min quickstart guide](https://angular.io/docs/ts/latest/quickstart.html), just add one line
```html
```
As for now `datepicker` is using `moment.js` to format date, so please update `system.js` config to contain mapping:
```html
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
},
map: {
moment: 'node_modules/moment/moment.js'
}
});
```
Add Ng2BootstrapModule as imported module in your application module `app.module.ts`
```ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Ng2BootstrapModule } from 'ng2-bootstrap/ng2-bootstrap';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, Ng2BootstrapModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
```
And update your `app.component.ts` to have following content:
```ts
import { Component } from 'angular2/core';
@Component({
selector: 'my-app',
template: `ng2-bootstrap hello world!`
})
export class AppComponent {
}
```
If you are using Angular [compiler-cli](https://github.com/angular/angular/tree/master/modules/%40angular/compiler-cli) don't forget bootstrap ModuleNgFactory instead of your common app module.
```shell
$ ./node_modules/.bin/ngc -p tsconfig.json
```
```ts
import { AppModuleNgFactory } from './app.module.ngfactory'
platformBrowserDynamic().bootstrapModuleFactory(AppModuleNgFactory);
```
And you are ready to go! :)
## API
Check demo for API [documentation](http://valor-software.github.io/ng2-bootstrap/)
## Contribution
Please read central `ng2` modules [readme](https://github.com/valor-software/ng2-plans) for details, plans and approach and welcome :)
## Credits
Crossbrowser testing sponsored by [Browser Stack](https://www.browserstack.com)
[](https://www.browserstack.com)