@@ -10,8 +10,7 @@ import {InjectionToken} from '@angular/core';
1010import { NgControl , FormGroupDirective , NgForm } from '@angular/forms' ;
1111
1212/** Injection token that can be used to specify the global error options. */
13- export const MD_ERROR_GLOBAL_OPTIONS =
14- new InjectionToken < ErrorOptions > ( 'md-error-global-options' ) ;
13+ export const MD_ERROR_GLOBAL_OPTIONS = new InjectionToken < ErrorOptions > ( 'md-error-global-options' ) ;
1514
1615export type ErrorStateMatcher =
1716 ( control : NgControl , parentFormGroup : FormGroupDirective , parentForm : NgForm ) => boolean ;
@@ -20,26 +19,24 @@ export interface ErrorOptions {
2019 errorStateMatcher ?: ErrorStateMatcher ;
2120}
2221
23- export class DefaultErrorStateMatcher {
22+ export function defaultErrorStateMatcher ( control : NgControl , formGroup : FormGroupDirective ,
23+ form : NgForm ) : boolean {
2424
25- errorStateMatcher ( control : NgControl , formGroup : FormGroupDirective , form : NgForm ) : boolean {
26- const isInvalid = control && control . invalid ;
27- const isTouched = control && control . touched ;
28- const isSubmitted = ( formGroup && formGroup . submitted ) ||
29- ( form && form . submitted ) ;
25+ const isInvalid = control && control . invalid ;
26+ const isTouched = control && control . touched ;
27+ const isSubmitted = ( formGroup && formGroup . submitted ) ||
28+ ( form && form . submitted ) ;
3029
31- return ! ! ( isInvalid && ( isTouched || isSubmitted ) ) ;
32- }
30+ return ! ! ( isInvalid && ( isTouched || isSubmitted ) ) ;
3331}
3432
35- export class ShowOnDirtyErrorStateMatcher {
33+ export function showOnDirtyErrorStateMatcher ( control : NgControl , formGroup : FormGroupDirective ,
34+ form : NgForm ) : boolean {
3635
37- errorStateMatcher ( control : NgControl , formGroup : FormGroupDirective , form : NgForm ) : boolean {
38- const isInvalid = control && control . invalid ;
39- const isDirty = control && control . dirty ;
40- const isSubmitted = ( formGroup && formGroup . submitted ) ||
41- ( form && form . submitted ) ;
36+ const isInvalid = control && control . invalid ;
37+ const isDirty = control && control . dirty ;
38+ const isSubmitted = ( formGroup && formGroup . submitted ) ||
39+ ( form && form . submitted ) ;
4240
43- return ! ! ( isInvalid && ( isDirty || isSubmitted ) ) ;
44- }
41+ return ! ! ( isInvalid && ( isDirty || isSubmitted ) ) ;
4542}
0 commit comments