Skip to main content
cngx-src documentation

withErrorStrategy

Functionforms/field

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

Description#

Configures the error visibility strategy used by CngxFormFieldPresenter.showError.

Pass a built-in name ('onTouched', 'onDirty', 'onSubmit', 'onTouchedOrSubmit', 'always') or a custom ErrorStrategyFn. The strategy fully overrides the default gate (touched OR errorScope.showErrors).

built-in

provideFormField(withErrorStrategy('onSubmit'))

custom

provideFormField(withErrorStrategy(
  (c) => c.invalid && (c.dirty || c.submitted),
))

Signature#

withErrorStrategy(strategy)

Parameters#

@paramstrategy

Returns#

FormFieldFeature