Skip to main content
cngx-src documentation

CngxTrim

DirectivePrimaryv0.2.0WCAG AA

projects/forms/input/trim.directive.ts

Import#

import { CngxTrim } from '@cngx/forms/input'

Description#

Normalizes whitespace and Unicode form on blur.

Place on the <input> or <textarea>. On blur it Unicode-NFC-normalizes the value, optionally collapses internal whitespace runs to a single space (cngxTrimCollapse), and trims the ends. When the value changes it writes back and dispatches a native input event, so a bound [field] / CngxInput sees the normalized value through the existing DOM->signal path - this is a deliberate imperative DOM normalizer, not a second managed copy.

Kept separate from CngxInputFormat so a format/parse atom is not overloaded with normalization (Pillar 3).

<input cngxInput cngxTrim [field]="f.name" />
<textarea cngxTrim cngxTrimCollapse [field]="f.bio"></textarea>

https://cngxjs.github.io/cngx/examples/#/forms/input/trim-on-blur

Metadata#

Host#

Index#

Inputs

HostListeners

Inputs#

collapse#
input()

Collapse internal whitespace runs to a single space. Opt-in.

default false, { alias: 'cngxTrimCollapse', transform: booleanAttribute }

HostListeners#

EventHandler
(blur)blur()