Getting started with nxt-pick-datetime
Installing
npm install --save nxt-pick-datetimeConfigure DateTime adapter provider
The date & time picker was built to be date implementation agnostic. It comes with two date adapter implementations, or you can provide your own adapter by implementing DateTimeAdapter (see documentation).
provideNativeDateTimeAdapter- support for native JavaScript Date objectprovideMomentDateTimeAdapter- support for MomentJs
import { ApplicationConfig } from '@angular/core'
import { provideNativeDateTimeAdapter } from 'nxt-pick-datetime/native-adapter'
export const appConfig: ApplicationConfig = {
providers: [
provideNativeDateTimeAdapter()
]
}Use it in a template
<input [nxtDateTime]="picker"
[nxtDateTimeTrigger]="picker"
placeholder="Date and time">
<nxt-date-time #picker></nxt-date-time>
Configuration options
nxt-date-time
| Input | Type | Default value | Description |
|---|---|---|---|
| [showSecondsTimer] | false | When true, shows a timer to configure the seconds value | |
| [hour12Timer] | false | When true, the timer will be in 12-hour format mode | |
| [backdropClass] | string | string[] | undefined | Custom class for the picker backdrop |
| [startView] | ViewType | 'month' | The view that the calendar should start on |
| [panelClass] | string | string[] | undefined | Custom class for the picker overlay pane |
| [stepHour] | 1 | Hours to change per step | |
| [startAt] | T | undefined | The date to show when picker opens Defaults to selected date (if available) or current date. |
| [stepMinute] | 1 | Minutes to change per step | |
| [stepSecond] | 1 | Seconds to change per step | |
| [firstDayOfWeek] | 0 | Set the first day of week Valid values are from 0 [Sunday] to 6 [Saturday] | |
| [hideOtherMonths] | false | If true, don't show dates from preious / next month on the calendar month view | |
| [pickerType] | PickerType | 'both' | Set the type of the dateTime picker
|
| [pickerMode] | PickerMode | 'popup' | The style the picker would open as
|
| [disabled] | boolean | false | Whether the date time picker should be disabled |
| [isOpen] | boolean | false | Whether the calendar is open |
| [scrollStrategy] | ScrollStrategy | BlockScrollStrategy | The scroll strategy when the picker is open (see CDK documentation) |
| Output | Type | Description |
|---|---|---|
| (open) | void | Callback when the picker is opened |
| (close) | void | Callback when the picker is closed |
| (yearSelected) | T | Emits selected year in multi-year view This doesn't imply a change on the selected date. |
| (monthSelected) | T | Emits selected month in year view This doesn't imply a change on the selected date. |
| (isOpenChange) | boolean | Emits when picker open state changes |
input[nxtDateTime]
| Input | Type | Default value | Description |
|---|---|---|---|
| [nxtDateTime] | DateTimeComponent<T> | undefined | The date & time picker this input is associated with |
| [dateTimeFilter] | DateFilter<T> | undefined | A function to filter available date & time |
| [disabled] | boolean | false | Whether the date & time picker input is disabled |
| [min] | T | undefined | The minimum valid date |
| [max] | T | undefined | The maximum valid date |
| [selectMode] | SelectMode | 'single' | The picker select mode
|
| [rangeSeparator] | '~' | The character to separate the 'from' and 'to' in input value | |
| [value] | T | undefined | |
| [values] | Array<T> | undefined |
| Output | Type | Description |
|---|---|---|
| (dateTimeChange) | DateTimeInputEvent<T> | Callback to invoke when |
| (dateTimeInput) | DateTimeInputEvent<T> | Callback to invoke when an |
[nxtDateTimeTrigger]
| Input | Type | Default value | Description |
|---|---|---|---|
| [dtPicker] | DateTimeComponent<T> | undefined, { alias: 'nxtDateTimeTrigger' } | |
| [disabled] | boolean | false |
nxt-date-time-inline
| Input | Type | Default value | Description |
|---|---|---|---|
| [showSecondsTimer] | false | When true, shows a timer to configure the seconds value | |
| [hour12Timer] | false | When true, the timer will be in 12-hour format mode | |
| [startView] | ViewType | 'month' | The view that the calendar should start on |
| [pickerType] | PickerType | 'both' | Set the type of the dateTime picker
|
| [stepHour] | 1 | Hours to change per step | |
| [stepMinute] | 1 | Minutes to change per step | |
| [stepSecond] | 1 | Seconds to change per step | |
| [disabled] | boolean | false | Whether the date time picker should be disabled |
| [firstDayOfWeek] | 0 | Set the first day of week Valid values are from 0 [Sunday] to 6 [Saturday] | |
| [hideOtherMonths] | false | If true, don't show dates from preious / next month on the calendar month view | |
| [selectMode] | SelectMode | 'single' | The picker select mode
|
| [startAt] | T | undefined | The date to show when picker opens Defaults to selected date (if available) or current date. |
| [dateTimeFilter] | DateFilter<T> | undefined | A function to filter available date & time |
| [min] | T | undefined | The minimum valid date |
| [max] | T | undefined | The maximum valid date |
| [value] | T | undefined | |
| [values] | Array<T> | undefined |
| Output | Type | Description |
|---|---|---|
| (yearSelected) | T | Emits selected year in multi-year view This doesn't imply a change on the selected date. |
| (monthSelected) | T | Emits selected month in year view This doesn't imply a change on the selected date. |
nxt-components