@busacca/ng-pick-datetime

中文文档
13.0.1发布于 2022/12/19TypeScriptES Module近 30 天下载 3463

Angular Date Time Picker

原始使用文档
文档目录17 节
  1. Breaking Changes
  2. Description
  3. How to Use
  4. Animation
  5. Choose a date implementation
  6. Properties for owl-date-time
  7. Events for owl-date-time
  8. Properties for input[owlDateTime]
  9. Events for input[owlDateTime]
  10. Properties for [owlDateTimeTrigger]
  11. Properties for [owlDateTimeTrigger]
  12. Properties for owl-date-time-inline
  13. Localization and DateTime Format
  14. Dependencies
  15. Demo
  16. License
  17. Author

Angular Date Time Picker

npm npm

Angular date time picker - Angular reusable UI component This package supports Angular 9+

Breaking Changes

  • Since 9.0.0 the picker has been updated for Angular 9+ apps
  • Since 8.0.0 the picker has been updated for Angular 8+ apps.
  • Since 7.0.0 the picker has been updated for Angular 7+ apps.

Description

Simple Angular date time picker. Online doc is here, Online demo(StackBlitz) is here. This picker is responsive design, so feel free to try it in your desktops, tablets and mobile devices.

How to Use

  1. Install with npm:npm install ng-pick-datetime --save

  2. Add styles. If you are using Angular CLI, you can add this to your styles.css:

    @import "~ng-pick-datetime/assets/style/picker.min.css";
    

    or if you prefer to use sass:

    @import "~ng-pick-datetime/assets/style/picker.scss";
    

    If you are not using the Angular CLI, you can include the picker.min.css via a <link> element in your index.html.

  3. Add OwlDateTimeModule and OwlNativeDateTimeModule to your @NgModule like example below

     import { NgModule } from '@angular/core';
     import { BrowserModule } from '@angular/platform-browser';
     import { MyTestApp } from './my-test-app';
    
     import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
    
     @NgModule({
         imports: [ 
             BrowserModule, 
             OwlDateTimeModule, 
             OwlNativeDateTimeModule,
         ],
         declarations: [ MyTestApp ],
         bootstrap:    [ MyTestApp ]
     })
     export class MyTestAppModule {}
    
  4. Connecting a picker to an input and a trigger.

    <input [owlDateTime]="dt1" [owlDateTimeTrigger]="dt1" placeholder="Date Time">
    <owl-date-time #dt1></owl-date-time>
    
    <input [owlDateTime]="dt2" placeholder="Date Time">
    <span [owlDateTimeTrigger]="dt2"><i class="fa fa-calendar"></i></span>
    <owl-date-time #dt2></owl-date-time>
    

    The examples above are quite basic. The picker has much more features, and you could learn more about those from demo page.

Animation

This picker uses angular animations to improve the user experience, therefore you need to install @angular/animations and import BrowserAnimationsModule to your application.

npm install @angular/animations --save
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        //...
    ],
    //...
})
export class YourAppModule { }

If you prefer to disable animation effect, use NoopAnimationsModule instead.

Choose a date implementation

The date-time picker was built to be date implementation agnostic. Developers need to make sure to provide the appropriate pieces for the picker to work with their chosen implementation. There are two pre-made modules, users need to import one of them or build your own one (learn more about this from here).

  • OwlNativeDateTimeModule - support for native JavaScript Date object
  • OwlMomentDateTimeModule - support for MomentJs

Properties for owl-date-time

NameTypeRequiredDefaultDescription
pickerTypeboth, calendar, timerOptionalbothSet the type of the dateTime picker. both: show both calendar and timer, calendar: only show calendar, timer: only show timer.
pickerModepopup, dialogOptionalpopupThe style the picker would open as.
startViewmonth, year, multi-yearOptionalmonthThe view that the calendar should start in.
startAtT/nullOptionalnullThe moment to open the picker to initially.
firstDayOfWeeknumberOptional0Set the first day of week. Valid value is from 0 to 6. 0: Sunday ~ 6: Saturday
showSecondsTimerbooleanOptionalfalseWhen specify it to true, it would show a timer to configure the second's value
hideOtherMonthsbooleanOptionalfalseWhether to hide dates in other months at the start or end of the current month
hour12TimerbooleanOptionalfalseWhen specify it to true, the timer would be in hour12 format mode
stepHournumberOptional1Hours to change per step.
stepMinutenumberOptional1Minutes to change per step.
stepSecondnumberOptional1Seconds to change per step.
scrollStrategyScrollStrategyOptionalBlockScrollStrategyDefine the scroll strategy when the picker is open. Learn more this from https://material.angular.io/cdk/overlay/overview#scroll-strategies.
disabledbooleanOptionalfalseWhen specify to true, it would disable the picker.
backdropClassstring/string[]OptionalnullCustom class for the picker backdrop.
panelClassstring/string[]OptionalnullCustom class for the picker overlay panel.

Events for owl-date-time

EventsParameterDescription
afterPickerOpennullCallback to invoke when the picker is opened
afterPickerClosednullCallback to invoke when the picker is closed.
yearSelectedTCallback to invoke when the year is selected.This doesn't imply a change on the selected date.
monthSelectedTCallback to invoke when the month is selected.This doesn't imply a change on the selected date.

Properties for input[owlDateTime]

NameTypeRequiredDefaultDescription
owlDateTimeOwlDateTimeComponent<T>RequirenullThe date time picker that this input is associated with.
owlDateTimeFilter( date: T)=>boolean OptionalnullA function to filter date time.
disabledbooleanOptionalfalseWhen specify to true, it would disable the picker's input.
min<T>OptionalnullThe minimum valid date time.
max<T>OptionalnullThe maximum valid date time.
selectModesingle, range, rangeFrom, rangeToOptionalsingleSpecify the picker's select mode. single: a single value allowed, range: allow users to select a range of date-time, rangeFrom: the input would only show the 'from' value and the picker could only selects 'from' value, rangeTo: the input would only show the 'to' value and the picker could only selects 'to' value.
rangeSeparatorstringOptional~The character to separate the 'from' and 'to' in input value in range selectMode.

Events for input[owlDateTime]

EventsParameterDescription
dateTimeChangesource: OwlDateTimeInput, value: input value, input: the input elementCallback to invoke when change event is fired on this <input [owlDateTime]>
dateTimeInputsource: OwlDateTimeInput, value: input value, input: the input elementCallback to invoke when an input event is fired on this <input [owlDateTime]>.

Properties for [owlDateTimeTrigger]

NameTypeRequiredDefaultDescription
owlDateTimeTriggerOwlDateTimeComponent<T>RequirenullThe date time picker that this trigger is associated with.
disabledbooleanOptionalfalseWhen specify to true, it would disable the trigger.

Properties for [owlDateTimeTrigger]

NameTypeRequiredDefaultDescription
owlDateTimeTriggerOwlDateTimeComponent<T>RequirenullThe date time picker that this trigger is associated with.
disabledbooleanOptionalfalseWhen specify to true, it would disable the trigger.

Properties for owl-date-time-inline

NameTypeRequiredDefaultDescription
pickerTypeboth, calendar, timerOptionalbothSet the type of the dateTime picker. both: show both calendar and timer, calendar: only show calendar, timer: only show timer.
startViewmonth, year, multi-yearOptionalmonthThe view that the calendar should start in.
startAtT/nullOptionalnullThe moment to open the picker to initially.
firstDayOfWeeknumberOptional0Set the first day of week. Valid value is from 0 to 6. 0: Sunday ~ 6: Saturday
showSecondsTimerbooleanOptionalfalseWhen specify it to true, it would show a timer to configure the second's value
hideOtherMonthsbooleanOptionalfalseWhether to hide dates in other months at the start or end of the current month
hour12TimerbooleanOptionalfalseWhen specify it to true, the timer would be in hour12 format mode
stepHournumberOptional1Hours to change per step.
stepMinutenumberOptional1Minutes to change per step.
stepSecondnumberOptional1Seconds to change per step.
disabledbooleanOptionalfalseWhen specify to true, it would disable the picker.
owlDateTimeFilter( date: T)=>boolean OptionalnullA function to filter date time.
min<T>OptionalnullThe minimum valid date time.
max<T>OptionalnullThe maximum valid date time.
selectModesingle, range, rangeFrom, rangeToOptionalsingleSpecify the picker's select mode. single: a single value allowed, range: allow users to select a range of date-time, rangeFrom: the input would only show the 'from' value and the picker could only selects 'from' value, rangeTo: the input would only show the 'to' value and the picker could only selects 'to' value.

Localization and DateTime Format

Localization for different languages and formats is defined by OWL_DATE_TIME_LOCALE and OWL_DATE_TIME_FORMATS. You could learn more about this from here.

Dependencies

none

Demo

  • Online doc is here
  • Online demo(StackBlitz) is here

License

  • License: MIT

Author

Daniel YK Pan

版本与发布记录

@busacca/ng-pick-datetime 共发布 17 个版本,首次发布于 2019/05/29;过去 12 个月发布了 0 个版本。

版本发布日期距今
13.0.1latest2022/12/193 年前
14.0.12022/12/193 年前
15.0.02022/12/193 年前
14.0.02022/12/193 年前
13.0.02022/12/193 年前
12.0.02021/06/285 年前

其他发布通道:next → 9.0.0-rc.9。

关于 @busacca/ng-pick-datetime 的常见问题

@busacca/ng-pick-datetime 是什么?

Angular Date Time Picker

如何安装 @busacca/ng-pick-datetime?

在项目目录运行 npm install @busacca/ng-pick-datetime,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/common(>= 13.0.0)、@angular/core(>= 13.0.0)、@angular/forms(>= 13.0.0)、@angular/cdk(>= 13.0.0)、moment(^2.29.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@busacca/ng-pick-datetime 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@busacca/ng-pick-datetime 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@busacca/ng-pick-datetime 可以商用吗?

@busacca/ng-pick-datetime 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@busacca/ng-pick-datetime 的下载量有多少?

根据 npm 官方下载统计,@busacca/ng-pick-datetime 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,463 次,日均约 115 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@busacca/ng-pick-datetime 还在维护吗?

最新版本 13.0.1 发布于 2022/12/19(3 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/05/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。