Simple Alert module for Angular version 2 and above.
npm install ng-alertSimple Alert module for Angular version 2 and above.
npm install ng-alert --save
1. Import NgAlertModule in your AppModule.
`` typescript
@NgModule({
imports: [
NgAlertModule // <-- import NgAlertModule in your app module
],
declarations: [...],
providers: [...]
})
export class NgAppModule { }
`
2. In your component :
` typescript
import { Component } from '@angular/core';
import { AlertService } from 'ng-alert';
@Component({
selector: 'app-component',
template:
App works!
,
styleUrls: ['./app.component.css']
})
export class AppComponent { constructor(private alertService: AlertService) {
// this line will push new success alert to alerts array
this.alertService.success('Your alert message goes here','The title', true);
}
}
``To get more help on the ng-alert contact me.