import { Injectable } from '@angular/core'; import { MatSnackBar, MatSnackBarConfig, MatSnackBarRef, SimpleSnackBar } from '@angular/material'; import { ComponentType } from '@angular/cdk/portal'; @Injectable({ providedIn: 'root' }) export class SnackBarService { public constructor(private matSnackBar: MatSnackBar) {} public open( message: string, action?: string, config?: MatSnackBarConfig ): MatSnackBarRef { return this.matSnackBar.open(message, action, config); } public openFromComponent( componentRef: ComponentType, config?: MatSnackBarConfig ): MatSnackBarRef { return this.matSnackBar.openFromComponent(componentRef, config); } }