cic-staff-client/src/app/_services/error-dialog.service.ts

26 lines
675 B
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
2021-05-10 18:15:25 +02:00
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { ErrorDialogComponent } from '@app/shared/error-dialog/error-dialog.component';
@Injectable({
2021-05-10 18:15:25 +02:00
providedIn: 'root',
})
export class ErrorDialogService {
public isDialogOpen: boolean = false;
2021-05-10 18:15:25 +02:00
constructor(public dialog: MatDialog) {}
openDialog(data): any {
if (this.isDialogOpen) {
return false;
}
this.isDialogOpen = true;
const dialogRef: MatDialogRef<any> = this.dialog.open(ErrorDialogComponent, {
width: '300px',
2021-05-10 18:15:25 +02:00
data,
});
2021-05-10 18:15:25 +02:00
dialogRef.afterClosed().subscribe(() => (this.isDialogOpen = false));
}
}