CngxErrorSource
projects/common/interactive/error-source/error-source.directive.ts
Import#
import { CngxErrorSource } from '@cngx/common/interactive'
Description#
Registers a single error condition with the nearest CngxErrorAggregator ancestor.
Pure DI propagation - no DOM output. The directive is a no-op when no
aggregator is present (the optional injection returns null).
Useful for surfacing errors that live outside the form-field
presenter, e.g. server-side validation, async availability checks,
or business-rule conflicts.
The when input takes a plain boolean. Consumers binding a signal
write [when]="form.email().invalid()" - the signal is invoked at the
binding site (canonical Angular pattern), mirroring CngxErrorState
discipline.
<fieldset cngxErrorAggregator>
<span cngxErrorSource="email-format" [when]="email().invalid()"
label="Email format invalid"></span>
<span cngxErrorSource="email-taken" [when]="serverErr() === 'taken'"
label="Email already in use"></span>
</fieldset>