Overview
TheDateRangePicker class provides a date range selection interface, allowing users to select both a start date and end date in a single picker. It’s ideal for booking systems, report generation, and any feature requiring a date range.
Inheritance
Constructor
Parameters
The unique identifier for the date range picker node in the DOM.
The placeholder text to display when no date range is selected.
The initial start date of the range.
The initial end date of the range.
Whether to display the node in a single line layout.
Material icon name to display in the picker field.
Custom error message to display when validation fails.
Whether the date range picker is disabled.
Synchronous validator function(s) or control options.
Asynchronous validator function(s) for the picker.
Action(s) to execute when a date range 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 | 'daterange' | The node type (read-only) |
startDate | string | The start date of the range |
endDate | string | The end date of the range |
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
Common Use Cases
Booking System
Report Generation
Data Filtering
Date Range Validation
Minimum Range Duration
Maximum Range Duration
See themaxRangeValidator example in the usage section above.
Business Days Only
Best Practices
Set Reasonable Constraints
Always setminDate and maxDate to prevent users from selecting irrelevant dates:
Provide Clear Feedback
Use descriptive error messages and hints:Handle Range Changes
Implement actions to respond to range changes:Related Node Types
- DatePicker - For selecting a single date
- DateTimePicker - For selecting date and time
- TimePicker - For selecting time only
- Input - Base input node for text values
