import { Component , Inject } from '@angular/core' ; import { FormControl , Validators } from '@angular/forms' ; import { MAT_DIALOG_DATA , MatDialogRef } from '@angular/material/dialog' ; import { Project } from '../../project' ; @ Component ( { selector : 'app-add-project' , templateUrl : './add-project.component.html' , styleUrls : [ './add-project.component.css' ] } ) export class AddProjectComponent { formControl = new FormControl ( '' , [ Validators . required ] ) ; constructor ( public dialogRef , @ Inject ( MAT_DIALOG_DATA ) public data ) { } getErrorMessage ( ) { return this . formControl . hasError ( 'required' ) ? 'Required field' : '' ; } onNoClick ( ) { this . dialogRef . close ( ) ; } }