2019-10-16 18:05:18 +09:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
2019-11-07 13:14:44 +09:00
|
|
|
import {
|
|
|
|
MatSnackBar,
|
|
|
|
MatSnackBarConfig,
|
|
|
|
MatSnackBarRef,
|
|
|
|
SimpleSnackBar
|
|
|
|
} from '@angular/material';
|
2020-01-10 09:37:29 +09:00
|
|
|
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
|
2019-11-07 13:14:44 +09:00
|
|
|
): MatSnackBarRef<SimpleSnackBar> {
|
|
|
|
return this.matSnackBar.open(message, action, config);
|
2019-10-16 18:05:18 +09:00
|
|
|
}
|
2020-01-10 09:37:29 +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
|
|
|
}
|