-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Cannot set custom global ErrorStateMatcher for lazy loaded modules #10084
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
Comments
Try this @NgModule({ providers: [ {provide: ErrorStateMatcher, useValue: new CustomErrorStateMatcher()} ] }) |
@shashikiran797 this is not working and I don't see why it would |
I have the same issue, did you get this fixed? |
Even I have the same issue, please let me know if anyone gets it fixed. |
I was facing the same issue, however after adding an empty constructor to the CustomErrorStateMatcher, it started working for me.
--
Hope this helps. |
Still an issue in Angular 9 / Material 9. The empty constructor @adnanmamajiwala mentioned does not work either. |
Issue still persists in Angular 10.1 As a workaround I need to copy |
Angular Material 10.2.5 (with angular 10.1.6) exhibits similar behaviour, and we do have quite a few lazy-loaded modules and I will for sure forget the workaround for one of them sooner or later ;) So yes, this would be really lovely. |
Angular Material 10.2.5, same issue, I have 2 lazy loaded modules: Core and Backoffice. The ShowOnDirtyErrorStateMatcher works fine in the Backoffice but not in Core which is very weird. |
I have the same issue, here using Angular 11 anyone have any solution? |
The solution is as @vmuresanu noted above.
|
This issue needs some attention because validation is the thing that is used in most of the apps. |
Still relevant, up |
Also works if provided in any module imported by all your lazy loaded modules. But still this need to be addressed especially since the best solution to #4190 is to use a different ErrorStateMatcher than the one provided. |
This issue also applies to standalone components. I have to import my custom ErrorStateMatcher (submitted = true) on each parent component. |
I can also confirm that there's an issue with standalone components, which is a big thing, since this is the way the Angular team is going. I had to provide ShowOnDirtyErrorStateMatcher in my standalone component's providers because it wasn't working when provided only (globally) in my appConfig. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
There should be ability to override ErrorStateMatcher for the whole application
What is the current behavior?
@NgModule({ providers: [ {provide: ErrorStateMatcher, useClass: CustomErrorStateMatcher} ] })
CustomErrorStateMatcher being provided in the application root module aren't applied inside of lazy loaded modules. Thus it is necessary to duplicate providing of custom error state matcher in every lazy loaded module.
What is the use-case or motivation for changing an existing behavior?
It is reasonable to have ability to override error state matcher bahavior for the whole app no matter it consists of lazy or non-lazy modules
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 5.1.3
Material 5.2.2
The text was updated successfully, but these errors were encountered: