
import { Component, HostListener } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';

@Component({
  template: 'app-nano-dialog-base'
})
export class NanoDialogBase<ChildDialogComponent>{
  constructor(public dialogRef: MatDialogRef<ChildDialogComponent>){

  }

  @HostListener('document:keydown.escape', ['$event']) 
  onKeydownHandler(event: KeyboardEvent) {
    this.dialogRef.close();
  }

  @HostListener('window:popstate', ['$event'])
  onPopState(event) {
    this.dialogRef.close();
  }
}