@@ -10,7 +10,6 @@ import {
1010 Directive ,
1111 DoCheck ,
1212 ElementRef ,
13- Inject ,
1413 Input ,
1514 OnChanges ,
1615 OnDestroy ,
@@ -19,15 +18,10 @@ import {
1918 Self ,
2019} from '@angular/core' ;
2120import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
22- import { FormControl , FormGroupDirective , NgControl , NgForm } from '@angular/forms' ;
21+ import { FormGroupDirective , NgControl , NgForm } from '@angular/forms' ;
2322import { Platform , getSupportedInputTypes } from '@angular/cdk/platform' ;
2423import { getMatInputUnsupportedTypeError } from './input-errors' ;
25- import {
26- defaultErrorStateMatcher ,
27- ErrorOptions ,
28- ErrorStateMatcher ,
29- MAT_ERROR_GLOBAL_OPTIONS
30- } from '@angular/material/core' ;
24+ import { ErrorStateMatcher } from '@angular/material/core' ;
3125import { Subject } from 'rxjs/Subject' ;
3226import { MatFormFieldControl } from '@angular/material/form-field' ;
3327
@@ -75,7 +69,6 @@ export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy,
7569 protected _required = false ;
7670 protected _id : string ;
7771 protected _uid = `mat-input-${ nextUniqueId ++ } ` ;
78- protected _errorOptions : ErrorOptions ;
7972 protected _previousNativeValue = this . value ;
8073 private _readonly = false ;
8174
@@ -130,7 +123,7 @@ export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy,
130123 }
131124 }
132125
133- /** A function used to control when error messages are shown. */
126+ /** An object used to control when error messages are shown. */
134127 @Input ( ) errorStateMatcher : ErrorStateMatcher ;
135128
136129 /** The input element's value. */
@@ -163,12 +156,10 @@ export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy,
163156 @Optional ( ) @Self ( ) public ngControl : NgControl ,
164157 @Optional ( ) protected _parentForm : NgForm ,
165158 @Optional ( ) protected _parentFormGroup : FormGroupDirective ,
166- @ Optional ( ) @ Inject ( MAT_ERROR_GLOBAL_OPTIONS ) errorOptions : ErrorOptions ) {
159+ private _defaultErrorStateMatcher : ErrorStateMatcher ) {
167160
168161 // Force setter to be called in case id was not specified.
169162 this . id = this . id ;
170- this . _errorOptions = errorOptions ? errorOptions : { } ;
171- this . errorStateMatcher = this . _errorOptions . errorStateMatcher || defaultErrorStateMatcher ;
172163
173164 // On some versions of iOS the caret gets stuck in the wrong place when holding down the delete
174165 // key. In order to get around this we need to "jiggle" the caret loose. Since this bug only
@@ -231,9 +222,9 @@ export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy,
231222 /** Re-evaluates the error state. This is only relevant with @angular/forms. */
232223 protected _updateErrorState ( ) {
233224 const oldState = this . errorState ;
234- const ngControl = this . ngControl ;
235225 const parent = this . _parentFormGroup || this . _parentForm ;
236- const newState = ngControl && this . errorStateMatcher ( ngControl . control as FormControl , parent ) ;
226+ const matcher = this . errorStateMatcher || this . _defaultErrorStateMatcher ;
227+ const newState = matcher . isErrorState ( this . ngControl , parent ) ;
237228
238229 if ( newState !== oldState ) {
239230 this . errorState = newState ;
0 commit comments