mgcrea.ngStrap.datepicker
Add datepicker functionality with any form text input.
Datepickers require the tooltip module and dateParser helper module to be loaded.
This module leverages the $locale service. You just have to load the proper i18n file to seamlessly translate your datepickers.
$scope.selectedDate = {{selectedDate}}; // <- {{ getType('selectedDate') }} $scope.selectedDateAsNumber = {{selectedDateAsNumber}}; // <- {{ getType('selectedDateAsNumber') }} $scope.fromDate = {{fromDate}}; // <- {{ getType('fromDate') }} $scope.untilDate = {{untilDate}}; // <- {{ getType('untilDate') }}
Append a bs-datepicker
attribute to any element to enable the directive.
$datepicker
serviceAvailable for programmatic use (mainly in directives as it requires a DOM element).
var myDatepicker = $datepicker(element, ngModelController);
Options can be passed via data-attributes on the directive or as an object hash to configure the service. For data attributes, append the option name to data-
, as in data-animation=""
.
You can position your select in corners (such as bottom-left
) or any other combination two.
Exotic placement options are not part of the Bootstrap's core, to use them you must use bootstrap-additions.css
from the BootstrapAdditions project. This project being not yet fully released, meanwhile, you can use the development snapshot compiled for theses docs.
Name | type | default | description |
---|---|---|---|
animation | string | am-fade | apply a CSS animation powered by ngAnimate |
placement | string | 'bottom-left' | how to position the typeahead - top | bottom | left | right, or any combination like bottom-left. |
trigger | string | 'focus' | how typeahead is triggered - click | hover | focus | manual |
html | boolean | false | replace ng-bind with ng-bind-html , requires ngSanitize to be loaded |
delay | number | object | 0 |
delay showing and hiding the typeahead (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is:
|
container | string | false | false |
Appends the typeahead to a specific element. Example:
|
template | path | id | '$typeahead' |
If provided, overrides the default template, can be either a remote URL or a cached template id. |
dateFormat | string | 'shortDate' |
Rendering format of your date, leverages ng.filter:date. |
dateType | string | 'date' |
Expected model type of your date - date | number | iso | string |
autoclose | boolean | false |
Whether the picker should close itself upon select. |
useNative | boolean | false |
Whether to use a native component if available (iOS/Android). |
minDate | date* | -Infinity |
Minimum allowed date for selection (* fed into the |
maxDate | date* | +Infinity |
Maximum allowed date for selection (* fed into the |
startView | number | 0 |
View that sould be opened by default - 0 | 1 | 2. |
minView | number | 0 |
Minimum allowed view - 0 | 1 | 2. 1 will only allow month selection. |
startWeek | number | 1 |
First day of the week. |
You can override global defaults for the plugin with $datepickerProvider.defaults
angular.module('myApp')
.config(function($datepickerProvider) {
angular.extend($datepickerProvider.defaults, {
dateFormat: 'dd/MM/yyyy',
startWeek: 1
});
})