Native AngularJS datetime picker directive styled by Twitter Bootstrap
Display a calendar embedded in the page.
Allows the user to select a date/time directly on the page
You can pass configuration options as a function or an object.
- Selected Date: {{ data.date | date:'yyyy-MM-dd a' }}
- <datetimepicker data-ng-model="data.embeddedDate"
- data-datetimepicker-config="{ startView:'day', minView:'day' }" />
Display the calendar inside a bootstrap dropdown component.
Allows the user to select a date/time from a drop-down component to save space on the page.
Use bootstrap's dropdown component to display/hide calendar.
Selected Date: {{ data.dateDropDownLink | date:'yyyy-MM-dd HH:mm a' }} <div class="dropdown"> <a class="dropdown-toggle" id="dropdown1" role="button" data-toggle="dropdown" data-target="#" href="#">Click here to show calendar</a> <ul class="dropdown-menu" role="menu"> <datetimepicker data-ng-model="data.dateDropDownLink" data-datetimepicker-config="{ dropdownSelector: '#dropdown1' }"/> </ul> </div>
Allows the user to select a date/time from a drop-down component to save space on the page.
Use bootstrap's dropdown component to display/hide calendar.
- <div class="dropdown">
- <a class="dropdown-toggle" id="dropdown2" role="button" data-toggle="dropdown" data-target="#" href="#">
- <div class="input-group"><input type="text" class="form-control" data-ng-model="data.dateDropDownInput"><span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
- </div>
- </a>
- <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
- <datetimepicker data-ng-model="data.dateDropDownInput" data-datetimepicker-config="{ dropdownSelector: '#dropdown2' }"/>
- </ul>
- </div>
Prevent the user from accidentally selecting an end date that is before the start date.
See the Read me file
Attribute on datetimepicker element
Function. Default: null
If the value of the before-render attribute is a function, the date time picker will call this function before rendering a new view, passing in data about the view.
<datetimepicker data-ng-model="data.date" data-before-render="beforeRender($view, $dates, $leftDate, $upDate, $rightDate)"></datetimepicker>
This function will be called every time a new view is rendered.
$scope.beforeRender = function ($view, $dates, $leftDate, $upDate, $rightDate) {
var index = Math.floor(Math.random() * $dates.length);
$dates[index].selectable = false;
}
The following parameters are supplied by this directive :
DateObject {
utcDateValue: Number - UTC time value of this date object. It does NOT contain time zone information so take that
into account when comparing to other dates (or use localDateValue function).
localDateValue: FUNCTION that returns a Number - local time value of this date object - same as moment.valueOf() or
Date.getTime().
display: String - the way this value will be displayed on the calendar.
active: true | false | undefined - indicates that date object is part of the model value.
selectable: true | false | undefined - indicates that date value is selectable by the user.
past: true | false | undefined - indicates that date value is prior to the date range of the current view.
future: true | false | undefined - indicates that date value is after the date range of the current view.
}
Setting the .selectable property of a DateObject to false will prevent the user from being able to select that date value.
Attribute on datetimepicker element
Function. Default: null
If the value of the on-set-time attribute is a function, the date time picker will call this function passing in the selected value and previous value.
<datetimepicker data-ng-model="data.date" data-on-set-time="onTimeSet(newDate, oldDate)"></datetimepicker>
This function will be called when the user selects a value on the minView.
$scope.onTimeSet = function (newDate, oldDate) {
console.log(newDate);
console.log(oldDate);
}
data-on-set-time="onTimeSet()" <-- This will work
data-on-set-time="onTimeSet" <-- This will NOT work, the ()'s are required
The datetimepicker-config attribute defines the configuration options.
This attribute can be an object or a function.
String. Default: 'minute'
The view that will trigger date selection when the user clicks on one of the date/time values.
Number. Default: 5
The increment used to build the hour view. A button is created for each minuteStep minutes.
String. Default: 'day'
The view that the datetimepicker should show when it is opened.
Accepts values of :
String. Default: null
When used within a Bootstrap dropdown, the selector specified in dropdownSelector will toggle the dropdown when a date/time is selected.
String. Default: null
Accepts any string value
Causes the date/time picker to re-read its configuration when the specified event is received.
For example, perhaps the startView option in the configuration has changed and you would like the new configuration to be used. You can $broadcast the event to cause this directive to use the new configuration.
String. Default: null
Accepts any string value
Causes the date/time picker to re-render its view when the specified event is received.
For example, if you want to disable any dates or times that are in the past. You can $broadcast the event at an interval to disable times in the past (or any other time valid dates change).
angularjs-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 angularjs-bootstrap-datetimepicker license is located in the project repository for more information.
This project is maintained by dalelotts