Component · v2.7.0
NgbNumericInputComponent
Locale-aware numeric editing. Percent models use fractions: 0.05 displays as 5%.
Import
import { NgbNumericInputComponent } from '@angular-bootstrap/ngbootstrap';Selector:ngb-numeric-input
Declaration
class NgbNumericInputComponent implements ControlValueAccessor, Validator, OnChangesInputs
inputId
Native input ID for external label association; generated when omitted.
inputId: stringDefault:''
label
Visible label associated with the native input.
label: stringDefault:''
ariaLabel
Accessible name when a visible label is not supplied.
ariaLabel: stringDefault:''
ariaLabelledBy
Space-separated IDs of accessible naming elements.
ariaLabelledBy: stringDefault:''
ariaDescribedBy
Space-separated IDs of help or error messages.
ariaDescribedBy: stringDefault:''
locale
Explicit locale shared by server and browser.
locale: stringDefault:'en-US'
format
Display decimal numbers, currency amounts or fractional percentage models.
format: 'decimal' | 'currency' | 'percent'Default:'decimal'
currency
ISO currency code used by currency formatting.
currency: stringDefault:'USD'
precision
Maximum display fraction digits. Committed values round to this scale.
precision: numberDefault:2
min
Inclusive minimum model value; null removes the bound.
min: number | nullDefault:null
max
Inclusive maximum model value; null removes the bound.
max: number | nullDefault:null
step
Increment in model units (0.01 is one percentage point for percent format).
step: numberDefault:1
showButtons
Display native increment and decrement buttons.
showButtons: booleanDefault:true
required
Reject an empty value through Angular forms validation.
required: booleanDefault:false
readOnly
Keep focus and selection available while preventing edits.
readOnly: booleanDefault:false
disabled
Disable editing and remove the native controls from keyboard navigation.
disabled: booleanDefault:false
value
Current model value. Supports value/valueChange binding or Angular forms.
get value(): number | null
set value(value: number | null)Outputs
valueChange
Emits once when a valid draft commits or a step changes the value.
valueChange: EventEmitter<number | null>Methods
writeValue
writeValue(value: number | null): voidregisterOnChange
registerOnChange(fn: (value: number | null) => void): voidregisterOnTouched
registerOnTouched(fn: () => void): voidsetDisabledState
setDisabledState(disabled: boolean): voidregisterOnValidatorChange
registerOnValidatorChange(fn: () => void): voidvalidate
validate(_control: AbstractControl): ValidationErrors | nullcommit
Commit a valid draft; invalid text remains visible and leaves the model unchanged.
commit(): boolean