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

docs: provide example for global ErrorStateMatcher for standalone apps #29219

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michael-small
Copy link

@michael-small michael-small commented Jun 9, 2024

Relevant documentation page: https://material.angular.io/components/input/overview#changing-when-error-messages-are-shown
Edit: other page https://material.angular.io/components/select/overview#changing-when-error-messages-are-shown

ErrorStateMatcher is very useful, especially when added globally. This PR would add an example on how to use it globally in standalone applications.

@michael-small michael-small requested a review from a team as a code owner June 9, 2024 17:33
@michael-small michael-small requested review from amysorto and wagnermaciel and removed request for a team June 9, 2024 17:33
@angular-robot angular-robot bot added the area: docs Related to the documentation label Jun 9, 2024
1) "remove empty code block" I added an extra `ts` code block example on accident in the previous PR
2) "rename comment": Change `Module` to `NgModule` for the existing example
@@ -65,11 +65,19 @@ applies to all inputs. For convenience, `ShowOnDirtyErrorStateMatcher` is availa
globally cause input errors to show when the input is dirty and invalid.

```ts
// NgModule applications
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split these into 2 separate code blocks? When its shown as one, I worry people might think they need to copy the entire snippet

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Can it be two adjacent blocks like this

// NgModule applications
@NgModule({
  providers: [
    {provide: ErrorStateMatcher, useClass: ShowOnDirtyErrorStateMatcher}
  ]
})
// Standalone applications
export const appConfig: ApplicationConfig = {
  providers: [
    {provide: ErrorStateMatcher, useClass: ShowOnDirtyErrorStateMatcher}
  ]
};

or should the comments be pulled out into something like normal text above the blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs Related to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants