Note: Design to be used inside <mat-form-field> component from Angular Material .
A directive designed to format numeric input fields to adhere to locale-specific formatting rules, such as digit grouping (thousands separators), decimal mark usage (period or comma), and potentially other region-specific adjustments and to return a number value.
It uses the formatNumber function from the Angular }angular/common package for formatting the displayed value, which is also used by the DecimalPipe. Although the input type needs to be a type text to allow for locale-specific formatting, the emitted value will always be a number. If the value is truncated it will be rounded using the "to-nearest" method. This behaviour can be disabled by setting the disableDecimalRounding input to true.
Usage of the zxNumericInput directive
1000.2688 is the value passed to the inputs below.
Default usage
With no decimal rounding
With French locale and digits info "1.2-2"
import { ZxNumericInput } from '@zamolxis/numeric-input';
Selector: zxNumericInput
Exported as: zxNumericInput
true
, the input value will not be rounded when the displayed value is truncated. Default is false
. It is possible to configure the digitsInfo
, locale
and disableDecimalRounding
properties at the application (or component) level using the ZX_NUMERIC_INPUT_CONFIG
injection token, as shown below.