dialog.component.ts 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {Component, Inject, OnInit} from '@angular/core';
  2. import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
  3. @Component({
  4. selector: 'app-dialog',
  5. templateUrl: './dialog.component.html',
  6. })
  7. export class DialogComponent {
  8. message = 'آیا مطمئن هستید؟';
  9. //alert default
  10. type = 'alert';
  11. /**
  12. * @param {MatDialogRef<DialogComponent>} dialogRef baray amaliat dialog
  13. * @param data pass kardan etelaat be dialog
  14. */
  15. constructor(private dialogRef: MatDialogRef<DialogComponent>, @Inject(MAT_DIALOG_DATA) data) {
  16. if (data.message) {
  17. this.message = data.message;
  18. }
  19. if (data.type) {
  20. this.type = data.type;
  21. }
  22. }
  23. close() {
  24. this.dialogRef.close(false);
  25. }
  26. /**
  27. * برای بستن دیالوگ وقتی که requestType برابر 'yesno'بود
  28. */
  29. no() {
  30. this.close();
  31. }
  32. yes() {
  33. this.dialogRef.close(true);
  34. }
  35. }