32 lines
738 B
TypeScript
Raw Normal View History

2019-10-16 18:05:18 +09:00
import { Injectable } from '@angular/core';
import {
MatSnackBar,
MatSnackBarConfig,
MatSnackBarRef,
SimpleSnackBar
} from '@angular/material';
import { ComponentType } from '@angular/cdk/portal';
2019-10-16 18:05:18 +09:00
@Injectable({
providedIn: 'root'
})
export class SnackBarService {
public constructor(private matSnackBar: MatSnackBar) {}
public open(
message: string,
action?: string,
config?: MatSnackBarConfig
): MatSnackBarRef<SimpleSnackBar> {
return this.matSnackBar.open(message, action, config);
2019-10-16 18:05:18 +09:00
}
public openFromComponent<T, D = any>(
componentRef: ComponentType<T>,
config?: MatSnackBarConfig<D>
): MatSnackBarRef<T> {
return this.matSnackBar.openFromComponent<T>(componentRef, config);
}
2019-10-16 18:05:18 +09:00
}