Components: Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'

Created on 10 Oct 2017  路  8Comments  路  Source: angular/components

Bug, feature request, or proposal:

Seems like a bug..

What is the expected behavior?

For errorStateMatcher to bind to an input.

What is the current behavior?

Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'

What are the steps to reproduce?

Using angular material beta 12 and angular 4.4.4

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 4.4.4
Material 2.0.0-beta.12

Is there anything else we should know?

Just upgraded from beta 11 to beta 12 and with it had to upgrade to angular 4.4.4 but now for some reason I get Can't bind to 'errorStateMatcher' since it isn't a known property of 'input' in the browser console upon navigating to the app.

I have both the forms module and reactive forms module in my application.

All 8 comments

html template:

<md-form-field>
  <input
    mdInput
    placeholder='{{ label }}'
    [(ngModel)]='inputValue'
    [errorStateMatcher]='validate.bind(this)' />
  <md-error>
    {{ errorMessage }}
  </md-error>
</md-form-field>

This was a breaking change in beta.12. Instead of passing a function, you pass a class instance of type ErrorStateMatcher that has an isErrorState method.

Either way will work. I don't know which is better practice, but if you need access to some component state, that demo example is definitely the easiest. You can also do some DI trickery if you wish too,

https://github.com/angular/material2/blob/236198376e7fc43f004f1b1014b25d4555459743/src/lib/stepper/stepper.ts#L34-L64

I am still getting the same error using:

validate: ErrorStateMatcher = {
  isErrorState: (control: FormControl) => {
    return true;
  }
};

with

<md-form-field>
  <input
    mdInput
    placeholder='{{ label }}'
    [(ngModel)]='inputValue'
    [errorStateMatcher]='validate' />
  <md-error>
    {{ errorMessage }}
  </md-error>
</md-form-field>

I feel like I am missing something..

mdInput -> matInput

Same goes for md-form-field

Yep, that did it. Thanks guys!

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dzrust picture dzrust  路  3Comments

kara picture kara  路  3Comments

crutchcorn picture crutchcorn  路  3Comments

constantinlucian picture constantinlucian  路  3Comments

michaelb-01 picture michaelb-01  路  3Comments