How to create the common notification with ngx-bootstrap like toaster notification

Kevin - Dhinesh babu picture Kevin - Dhinesh babu · Jul 19, 2017 · Viewed 7.5k times · Source

I am new to angular 2& 4. I want to create the custom notification with ngx-bootstrap alerts and modal. I have searched and got some sample. But those are not simple. I just need a simple blueprint for create the notification with service,interface and component.

Please any one guide me with sample code.

Answer

Manubhargav picture Manubhargav · Jul 21, 2017

Official Documentation for ngx-bootstrap - Alerts.
Official Documentation for ngx-bootstrap - Modals.
API documentation and usage scenarios available there with practical examples.


For quick reference, I'll give you the code for a simple Alert box - Usage and demo below:

First things first, Import the ngx-bootstrap in your Root module using:

import { AlertModule } from 'ngx-bootstrap';

@NgModule({
  imports: [AlertModule.forRoot(),...]
})
export class AppModule(){}

Here goes HTML part template:

<alert type="success">
  <strong>Well done!</strong> You successfully read this important alert message.
</alert>

Code for Component given below:

import { Component } from '@angular/core';

@Component({
  selector: 'demo-alert-basic',
  templateUrl: './basic.html'
})
export class DemoAlertBasicComponent {}