0.0.0 • Published 8 years ago
ngx-alertbox
Licence
MIT
Version
0.0.0
Deps
11
Size
76 kB
Vulns
18
Weekly
0
ng5-alertbox
This project insert a
Usage
- Install with npm
npm install ng5-alertbox
- Import to project
import { NgxAlertboxModule } from './ngx-alertbox/ngx-alertbox.module'
@NgModule({
declarations: [],
imports: [
NgxAlertboxModule.forRoot({ })
],
providers: [],
bootstrap: []
})
export class AppModule { }
- Add
NgxAlertboxServiceto Coponent
import { NgxAlertboxService } from './ngx-alertbox/ngx-alertbox.service'
...
export class AppComponent {
constructor(
public boxService: NgxAlertboxService
) { }
}
Config and API
Configuration in NgxAlertBoxModule.forRoot({})
| Config | Usage |
|---|---|
autoRemove |
number of second to remove the alertbox, 0 to disable |
title |
set the title of the alertbox |
message |
set the message of the alertbox |
Add method to Typescript or HTML to create and remove the alertbox
| Method | Usage |
|---|---|
add() |
add a alertbox to the view |
clearLastOne() |
remove the oldest alertbox |
clearAll() |
reamove all the alertbox |
Example
...
// Configuartion in app.module.ts
imports: [
NgxAlertboxModule.forRoot({
autoRemove: 0,
title: "Title",
message: "Message",
})
],
// Create and Remove in component.ts
import { NgxAlertboxService } from './ngx-alertbox/ngx-alertbox.service'
...
export class AppComponent {
constructor(
public boxService: NgxAlertboxService
) { }
someMethod() {
// Do something here
this.boxService.add()
// Do others here
this.boxService.clearAll()
}
}
Roadmap
- Make it responsive
- Adding animation when alertbox enter and exit the view
- Adding more configuration api
Limitation
This library is only tested on Angular.io v5.0.0.