Component · v2.7.0
NgbMaskedInputComponent
Fixed masks: 0 = ASCII digit, A = ASCII letter, * = ASCII alphanumeric; backslash escapes literals.
Import
import { NgbMaskedInputComponent } from '@angular-bootstrap/ngbootstrap';Selector:ngb-masked-input
Declaration
class NgbMaskedInputComponent 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:''
mask
Required fixed mask. Use a backslash to escape a token as a literal.
mask: stringDefault:'000-000'
valueMode
Raw excludes mask literals; formatted includes them. Default raw.
valueMode: 'raw' | 'formatted'Default:'raw'
placeholder
Optional input hint; does not replace an accessible label.
placeholder: stringDefault:''
inputMode
Hint for the mobile keyboard; mask validation is independent of this hint.
inputMode: 'text' | 'numeric' | 'tel'Default:'text'
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(): string | null
set value(value: string | null)Outputs
valueChange
Emits normalized partial or complete values; incomplete input remains invalid.
valueChange: EventEmitter<string | null>Methods
writeValue
writeValue(value: string | null): voidregisterOnChange
registerOnChange(fn: (value: string | null) => void): voidregisterOnTouched
registerOnTouched(fn: () => void): voidregisterOnValidatorChange
registerOnValidatorChange(fn: () => void): voidsetDisabledState
setDisabledState(disabled: boolean): voidvalidate
validate(_control: AbstractControl): ValidationErrors | null