license import { Injectable } from '@angular/core' ; import { FormGroupDirective , NgForm , FormControl } from '@angular/forms' ; /** Provider that defines how form controls behave with regards to displaying error messages. */ @ Injectable ( { providedIn : 'root' } ) export class ErrorStateMatcher { isErrorState ( control , form ) { return ! ! ( control && control . invalid && ( control . touched || ( form && form . submitted ) ) ) ; } }