import { FormControl , FormGroupDirective , NgForm } from '@angular/forms' ; import { ErrorStateMatcher } from '@angular/material/core' ; export class MyErrorStateMatcher implements ErrorStateMatcher { isErrorState ( control , form ) { const isSubmitted = form && form . submitted ; return ! ! ( control && control . invalid && ( control . dirty || control . touched || isSubmitted ) ) ; } }