Overview
TheDatePicker class provides a date selection interface with calendar popup functionality. It supports date constraints through minimum and maximum date boundaries.
Inheritance
Constructor
Parameters
The unique identifier for the date picker node in the DOM.
The placeholder text to display when no date is selected.
The initial date value. Can be a Date object, string, or timestamp.
Whether to display the node in a single line layout.
Material icon name to display in the date picker field.
Custom error message to display when validation fails.
Whether the date picker is disabled.
Synchronous validator function(s) or control options.
Asynchronous validator function(s) for the date picker.
Action(s) to execute when a date is selected.
The minimum selectable date. Dates before this will be disabled.
The maximum selectable date. Dates after this will be disabled.
Properties
| Property | Type | Description |
|---|---|---|
id | string | The unique identifier for the node |
placeholder | string | The placeholder text |
type | 'date' | The node type (read-only) |
value | any | The selected date value |
readOnly | boolean | Whether the input field is read-only |
minDate | Date | Minimum selectable date |
maxDate | Date | Maximum selectable date |
singleLine | boolean | Whether displayed in single line layout |
icon | string | Material icon name |
errorMessage | string | Custom error message |
disabled | boolean | Whether the node is disabled |
validator | Validator | AbstractControlOptions | Synchronous validators |
asyncValidator | AsyncValidatorFn | Asynchronous validators |
action | Action | Action[] | Associated actions |
hint | string | Hint text to display |
autoFocus | boolean | Whether to auto-focus on load |
Methods
getNativeElement()
Returns the native DOM element for this node.Usage Example
Date Constraints
Minimum Date
SetminDate to prevent users from selecting dates before a certain point:
Maximum Date
SetmaxDate to prevent users from selecting dates after a certain point:
Date Formats
The date picker uses the locale-aware date format provided by Angular Material. The displayed format automatically adapts to the user’s locale settings.Validation
In addition to custom validators, the date picker automatically validates that selected dates fall within theminDate and maxDate range if specified.
Related Node Types
- DateTimePicker - For selecting both date and time
- TimePicker - For selecting time only
- DateRangePicker - For selecting a date range
- Input - Base input node for text values
