0.1.2 • Published 6 years ago
ng2-bootstrap-alert v0.1.2
ng2-bootstrap-alert
A simple Angular 2 library for displaying alert messages
Usage
- install library
npm i ng2-bootstrap-alert --save
- Install peer dependencies
- bootstrap
npm i bootstrap --save
- angular material icons
npm i material-design-icons --save
- bootstrap
- update .angular-cli.json
to include following css files under **styles** section -
../node_modules/material-design-icons/iconfont/material-icons.css`../node_modules/bootstrap/dist/css/bootstrap.min.css
- update your app.module.ts
- toimport {AlertModule} from 'ng2-bootstrap-alert';
- addAlertModule
in imports section - update your root (component) html to include
<alert></alert>
- From your components start using alert service to display messages
-
this.alertService.error("message",ttl,Position);
(import alert service and inject it into the component
Available Methods
Method | Description | Usage |
---|---|---|
error | displays errors | this.alertService.error("message") |
warn | dispalys warnings | this.alertService.warn("message") |
info | dispalys info | this.alertService.info("message") |
success | dispalys success | `this.alertService.success("message") |
Method Params
Param | Options | Required? | Default | Description |
---|---|---|---|---|
message | String | Yes | Message to display | |
ttl | int | No | 0 | time in sec to display the message |
position | PositionType.TOP_LEFT,PositionType.TOP_RIGHT,PositionType.BOTTOM_LEFT, PositionType.BOTOM_RIGHT,PositionType.DEFAULT | No | PositionType.DEFAULT | position of the message |