import { MAT_DIALOG_DATA , MatDialogRef } from '@angular/material/dialog' ; import { Component , Inject } from '@angular/core' ; import { DataService } from '../../services/data.service' ; import { FormControl , Validators } from '@angular/forms' ; import { Issue } from '../../models/issue' ; @ Component ( { selector : 'app-add.dialog' , templateUrl : '../../dialogs/add/add.dialog.html' , styleUrls : [ '../../dialogs/add/add.dialog.css' ] } ) export class AddDialogComponent { constructor ( public dialogRef , @ Inject ( MAT_DIALOG_DATA ) public data , public dataService ) { } formControl = new FormControl ( '' , [ Validators . required ] ) ; getErrorMessage ( ) { return this . formControl . hasError ( 'required' ) ? 'Required field' : this . formControl . hasError ( 'email' ) ? 'Not a valid email' : '' ; } submit ( ) { } onNoClick ( ) { this . dialogRef . close ( ) ; } public confirmAdd ( ) { this . dataService . addIssue ( this . data ) ; } }