import { Injectable } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; import { NotifierComponent } from './notifier/notifier.component'; @Injectable({ providedIn: 'root' }) export class NotifierService { constructor(private snackBar:MatSnackBar) { } showNotification(displayMessage:string, buttonText: string, messageType: 'error' | 'success') { this.snackBar.openFromComponent(NotifierComponent, { data: { message: displayMessage, buttonText: buttonText, type : messageType }, duration: 4000, verticalPosition: 'top', panelClass: [messageType] }) } }