Skip to main content

Angular 6 Toast Message Notifications From Scratch

Angular 6 Toast Message Notifications From Scratch

Today, We want to share with you Angular 6 Toast Message Notifications From Scratch.
In this post we will show you Angular 6 Alert Component, hear for Angular 6 Alert (Toaster) Notifications we will give you demo and example for implement.
In this post, we will learn about AngularJS 6 Toast Message Notifications with an example.

Angular 6 Example

Angular Latest My Previous Post With Source code Read more…..

  1. Angular 6 Folder Project Structure
  2. Angular 6 CLI Installation
  3. Angular 6 Module File
  4. Angular 6 Components
  5. Angular 6 Services
  6. Angular 6 Routing
  7. Angular 6 CSS
  8. Angular 6 Class Binding
  9. Angular 6 Animation
  10. Angular 6 Templating
  11. Angular 6 HTTP Client

The angular 6 Project alert or model dialog component HTML template Data contains the html display message for displaying alert dialo popup messages at the simple top of the main index page.

Also Read :  How to display cross domain json data using Jquery

<div *ngIf="status" [ngClass]="{ 'alert': status, 'alert-success': status.type === 'success', 'alert-danger': status.type === 'error' }">{{status.text}}</div>

Angular 6 Alert Component

Path: /src/app/_directives/alert.component.ts

The angular 6 alert dialog message component passes model alert messages to the HTML template whenever a simple message is send or received from the error , success alert service. It does this by some subscribing all the visitors to the alert angular 6 service’s getMessage() method which data content returns all the an Observable.

import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
 
import { AlertService } from '../_services';
 
@Component({
    selector: 'alert',
    templateUrl: 'alert.component.html'
})
 
export class AlertComponent implements OnInit, OnDestroy {
    private subscription: Subscription;
    status: any;
 
    constructor(private alertService: AlertService) { }
 
    ngOnInit() {
        this.subscription = this.alertService.getMessage().subscribe(status => { 
            this.status = status; 
        });
    }
 
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
}

Also Read :  Basic Computer Programming Languages Principles

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Angular 6 Alert Component Template.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Web Developer

Hi, I’m Web developer, PHP developer.Pakainfo.com is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development.Any visitors of this site are free to browse our tutorials, live demos, Examples and download scripts.If you have a project that you want to get started, launch quickly, contact me. Email : [email protected]