Skip to main content
cngx-src documentation

provideFormField

Functionforms/field

projects/forms/field/form-field.token.ts

Description#

Registers application-wide defaults for every CngxFormField in scope. Each with* feature contributes one slice of FormFieldConfig; features apply left to right, so a later feature overrides an earlier one on the same key.

Returns EnvironmentProviders, so it sits at an environment injector - bootstrapApplication's providers, or a lazy route's providers. It cannot be placed on a component. Resolution is nearest-wins and replace, not merge: a route-level provideFormField shadows the root one for that subtree rather than deep-merging into it.

bootstrapApplication(AppComponent, {
  providers: [
    provideFormField(
      withErrorMessages({ required: () => 'Required.' }),
      withConstraintHints(),
    ),
  ],
});

Signature#

provideFormField(...features: undefined)

Parameters#

@paramfeatures

Returns#

EnvironmentProviders