Native Angular (8+) datetime picker component styled by Twitter Bootstrap 4.
Read this in other languages: Spanish
Use install version 3.1.0
npm install angular-bootstrap-datetimepicker@3.1.0
See angularjs-bootstrap-datetimepicker
I know this is a tiny component but many people use it in production (high 5 to all of us) - if you happen to use this component please click the star button (at the top of the page) - it means a lot to all the contributors.
Peer dependencies:
jQuery is NOT required.
If you are using the Angular CLI there are a few simple steps toadd this component to your project.
First, install this module and it's peer dependencies.
npm install --save angular-bootstrap-datetimepicker bootstrap moment open-iconic
Then update ./src/app/app.module.ts
to include the following:
import { AppComponent } from './app.component';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';
import { DlDateTimeDateModule, DlDateTimePickerModule } from 'angular-bootstrap-datetimepicker';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
DlDateTimeDateModule, // <--- Determines the data type of the model
DlDateTimePickerModule,
],
providers: [FormsModule],
bootstrap: [AppComponent]
})
export class AppModule { }
Next, add the following to ./src/app/app.component.html
<dl-date-time-picker
startView="day"
maxView="year"
minView="minute"
minuteStep="5"
[(ngModel)]="selectedDate"
>
</dl-date-time-picker>
Next, add the following to ./src/styles.css
@import '~bootstrap/dist/css/bootstrap.min.css';
@import '~open-iconic/font/css/open-iconic-bootstrap.css';
Note: This component uses open-iconic
icons by default, but you can use any icon librarythat supports styling with classes
.
Finally, run npm start
and you should see the date/time picker on http://localhost:4200/
By default, the date/time picker is as wide as it's container { width:100% }
.It uses bootstrap's flex row
and col
classes to layout the date/time picker into rows and columns.If the parent container is too narrow (less than 340px in english), the row and column layout may wrap in ways that are not attractive.Other languages/locals may require a wider container to fit the contents.
The user interactions with a date-time picker make it difficult to write e2e tests that exactly replicate the users interaction with the picker.
Fortunately, this repository contains a file you can use in your e2e tests to cause the date/time picker to select any specified date.
See ./e2e/src/dl-date-time-picker-protractor.ts for details.
Use the automated configuration generator (please let me know if it does not work for your use case!),or see https://dalelotts.github.io/angular-bootstrap-datetimepicker/for the automatically generated documentation.
The first day of the week is determined by moment's i18n settings.For example, setting the locale to 'fr'
will cause Monday to be the first day of the week.
The format of hours and minutes is also determined by moment's i18n settings.
hours are displayed using ll
as the format.minutes are displayed using lll
as the format.
I recommend you use the default locale settings from Moment (if they are incorrect, submit a PR to moment to correct the settings)If for some reason the default Moment settings will not work, you can customize the existing locale or create a custom locale with the desired formats.
You can generate the documentation by running npm run documentation
or see https://dalelotts.github.io/angular-bootstrap-datetimepicker/
The DlDateTimePickerComponent
component adds aria-label
attributes to the left, right, and up buttonsin addition to all calendar cells where the text of the cell may not fully describe the value.
The DlDateTimePickerComponent
component supports the following keyboard shortcuts in all views:
Shortcut | Action |
---|---|
LEFT_ARROW |
Go to the cell to the left |
RIGHT_ARROW |
Go to the cell to the right |
UP_ARROW |
Go to the cell above |
DOWN_ARROW |
Go to the cell below |
HOME |
Go to the first cell in the view |
END |
Go to the last cell in the view |
PAGE_UP |
Go to the same cell in the previous time period |
PAGE_DOWN |
Go to the same cell in the next time period |
ENTER or SPACE |
Select current cell |
This view allows the user to select the year for the target date.If the year view is the minView, the date will be set to midnight on the first day of the year
This view allows the user to select the month in the selected year.If the month view is the minView, the date will be set to midnight on the first day of the month.
This view allows the user to select the the day of the month, in the selected month.If the day view is the minView, the date will be set to midnight on the day selected.
This view allows the user to select the hour of the day, on the selected day.If the hour view is the minView, the date will be set to the beginning of the hour on the day selected.
This view allows the user to select a specific time of day, in the selected hour.By default, the time is displayed in 5 minute increments. The minuteStep
property controls the increments of time displayed.If the minute view is the minView, which is is by default, the date will be set to the beginning of the hour on the day selected.
See Contributing.md
This component was written using TDD and all enhancements and changes have related tests.
We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use gulp:
npm install
npm test
The karma task will try to open Chrome as a browser in which to run the tests.Make sure Chrome is available or change the browsers setting in karma.config.js
angular-bootstrap-datetimepicker is released under the MIT license and is copyright 2015 Knight Rider Consulting, Inc.. Boiled down to smaller chunks, it can be described with the following conditions.
The full angular-bootstrap-datetimepicker license is located in the project repository for more information.
对于angular js 日期时间选择插件。网上实现的大多数只有日期选择,还有许多用到了jquery , 并不符合我的要求。包括ui-bootstrap 自带的,找了很久终于在github上找到一款。 我在具体使用过程中还是很感慨插件的强大,赞一个。同时也获得一个使用插件的心得,不要总想着为实现自己想要的功能,去改别人的东西,插件的功能强大,本身支持许多参数配置。当然实在没办法还得改。 1.引入3
直接上码: <!DOCTYPE html> <html ng-app="myApp"> <head lang="en"> <meta charset="UTF-8"> <title></title> <link href="bootstrap.css" rel="stylesheet" media="screen"> <link href="bootstrap-da
近期的一个项目,是用angular来写的,本来框架就是第一次接触,使用相关插件的时候就感觉更加没有头绪了,其中一个插件就是时间选择器。比较好用时间选择器就是bootstrap里面的datetimepicker和daterangepicker(详情见bootstrap里面的时间选择器笔记)。 项目需要的是一个可以选择时间段的时间选择器,按照比较正规的做法,是应该用directive来做,但是对出
问题内容: 我在尝试为Angular-Bootstrap编写茉莉花单元测试时遇到问题 。确切的错误是 `Expected spy open to have been called with [ { templateUrl : ‘/n/views/consent.html’, controller : ‘W2ConsentModal as w2modal’, resolve : { employee
问题内容: 我在很多方面都无法使用UI-Router。我不了解它如何与其他框架交互。 即,我正在尝试实现Bootstrap 3的导航栏折叠模块,如下所示: 这直接来自Bootstrap网站,在自己的.html页面中运行正常。 问题是当我将其插入UI-Router视图时。折叠动作不再起作用-我猜是因为“数据目标”功能以某种方式无法找到其目标。 如何将Bootstrap 3与Angular UI结合使
我正在我的项目中使用ng bootstrap。我所要做的就是打开一个模式。我读过一个类似的线程,但在那里,引导css不包括。 我正在效仿这个例子。 当我单击按钮打开模态时,模态会附加在DOM中(当使用dev工具检查时可见),但它在屏幕上不可见。 我已经在我的.Angular-cli.json中包含了引导css作为 当查看页面源时,引导css也可以在styles.bundle.js中看到。 编辑1:
本文向大家介绍angular bootstrap timepicker TypeError提示怎么办,包括了angular bootstrap timepicker TypeError提示怎么办的使用技巧和注意事项,需要的朋友参考一下 angular bootstrap timepicker TypeError: Cannot set property '$render' of undefined
问题内容: 我目前正在开发一个Web应用程序,该应用程序很好地使用了twitter-bootstrap和Angularjs。但是,我在将typeahead用作ng- model时遇到问题。 键入时一切正常,但是当我选择一个项目(建议)时,除非在选择值后更改文本框的值,否则该值不会反映在Angular控制器中。类型->选择->类型有效。类型->选择不起作用。 HTML: 角度代码: 我添加了一个ng
问题内容: 我目前正在机器上本地测试角度。当我尝试重新创建手风琴和对话框的示例时。我在控制台中收到此错误消息,提示模板丢失。 错误示例:404未找到-localhost / angular / template / message.html 当我查看指令时,有一个模板。 该指令的目的是什么? 下载整个有角度的zip文件时,这些模板是否应该包括在内? 我是否缺少应包含在标题中的其他文件? 问题答案: