Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
douglasrlee opened this issue Oct 10, 2017 · 8 comments

Comments

@douglasrlee
Copy link

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.

@douglasrlee
Copy link
Author

html template:

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

@willshowell
Copy link
Contributor

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.

@willshowell
Copy link
Contributor

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

@douglasrlee
Copy link
Author

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..

@willshowell
Copy link
Contributor

willshowell commented Oct 11, 2017

mdInput -> matInput

Same goes for md-form-field

@douglasrlee
Copy link
Author

Yep, that did it. Thanks guys!

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants