Tuesday, August 8, 2017

Using bootstrap in angular 2

To use bootstrap in angular 2  we need to add ngx-bootstrap



  • install ngx-bootstrap and bootstrap
  npm install ngx-bootstrap bootstrap --save
  • open src/app/app.module.ts and add

import { AlertModule } from 'ngx-bootstrap';
...

@NgModule({
   ...
   imports: [AlertModule.forRoot(), ... ],
    ... 
})
  • open .angular-cli.json and insert a new entry into the styles array
      "styles": [
         "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.css",
      ],
  • open src/app/app.component.html and add
<alert type="success">hello</alert>

1 comment: