mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
docs(forms): Add a section for automatic form binding (#66111)
To avoid manually adding classes like `.ng-valid`, `.ng-dirty` etc to every field, you can provide a global configuration using `provideSignalFormsConfig`. PR Close #66111
This commit is contained in:
parent
b0a4ecc50e
commit
cf57c01ca6
1 changed files with 21 additions and 0 deletions
|
|
@ -212,3 +212,24 @@ const formValue = computed(() => ({
|
|||
## Bottom-up migration
|
||||
|
||||
This is coming soon.
|
||||
|
||||
## Automatic status classes
|
||||
|
||||
To avoid manually adding classes like `.ng-valid`, `.ng-dirty` etc to every field, you can provide a global configuration using `provideSignalFormsConfig`.
|
||||
|
||||
```typescript
|
||||
import {provideSignalFormsConfig} from '@angular/forms/signals';
|
||||
|
||||
bootstrapApplication(App, {
|
||||
providers: [
|
||||
provideSignalFormsConfig({
|
||||
classes: {
|
||||
'ng-valid': ({state}) => state().valid(),
|
||||
'ng-invalid': ({state}) => state().invalid(),
|
||||
'ng-touched': ({state}) => state().touched(),
|
||||
'ng-dirty': ({state}) => state().dirty(),
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue