CngxNumericInput
projects/forms/input/numeric-input.directive.ts
Import#
import { CngxNumericInput } from '@cngx/forms/input'
Description#
Locale-aware numeric input directive.
Keeps type="text" (no browser spinners, no scroll-to-change) and uses
Intl.NumberFormat for formatting. Shows raw value on focus, formatted value on blur.
Supports Arrow Up/Down (+ Shift) for increment/decrement with min/max clamping.
<input cngxNumericInput #num="cngxNumericInput"
[min]="0" [max]="100" [step]="0.5" [decimals]="2" />
<span>Value: {{ num.numericValue() }}</span><!-- Currency input (always 2 decimals) -->
<input cngxNumericInput [decimals]="2" [min]="0" [locale]="'de-CH'" />
<!-- Integer-only -->
<input cngxNumericInput [decimals]="0" [allowNegative]="false" />Metadata#
Host#
Providers#
Relationships
Depends on1
Index#
Properties
Outputs
Derived State
HostBindings
HostListeners
Inputs#
number | undefinedMaximum decimal places. Falls back to global config. undefined = unlimited, 0 = integer only.
string | undefinedLocale for number formatting. Falls back to global config, then LOCALE_ID.
number | undefinedStep for increment/decrement via Arrow keys. Falls back to global config.
number | nullPrimary value channel. null when empty or invalid.
null, { alias: 'value' }Outputs#
Instance Properties#
Methods#
HostBindings#
| Binding | Expression |
|---|---|
[attr.inputmode] | "decimal" |
[attr.role] | "spinbutton" |
[attr.aria-valuemin] | min() ?? null |
[attr.aria-valuemax] | max() ?? null |
[attr.aria-valuenow] | numericValue() |
[style.font-variant-numeric] | "var(--cngx-numeric-input-numeric-variant, tabular-nums)" |
HostListeners#
| Event | Handler |
|---|---|
(beforeinput) | beforeinput() |
(keydown) | keydown() |
(focus) | focus() |
(blur) | blur() |
(paste) | paste() |