Thursday, August 31, 2017

ngx-bootstrap in angular 2


Create a new project
ng new wakeGenie

Create a new component
C:\Development\Wakegenie\webApp>ng generate component modal

Install bootstrap in angular 2



Adding 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>


No comments:

Post a Comment