Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js
npm install angular-moment-picker





Check out the homepage at http://indrimuska.github.io/angular-moment-picker/.
Angular Moment Picker is a native AngularJS directive for date and time picker that uses Moment.js and does not require jQuery.
Get Angular Moment Picker from npm, bower or git:
```
npm install angular-moment-picker
bower install moment-picker
git clone https://github.com/indrimuska/angular-moment-picker.git
Include style and script in your page:
`html`
Add moment-picker dependency to your module:
`js`
var myApp = angular.module('myApp', ['moment-picker']);
Provide the attribute to your element:
`html` {{ myDate }}
Check out the demo page at http://indrimuska.github.io/angular-moment-picker/.
Decade view | Year view | Month view
:---:|:---:|:---:
!Decade view | !Year view | !Month view
Day view | Hour view | Minute view
!Day view | !Hour view | !Minute view
Angular Moment Picker provides the following additional themes. Each theme has a dedicate stylesheet to be included in the application the overrides the default style.
- Material UI - Plunker
`html`
A preview of the each theme is available here.
To configure Angular Moment Picker you have to add to your element or your input the attribute relative to the options you want to set.
`html`
Mon anniversaire est le {{ ctrl.birthday }}
`html`
Property | Default | Description | Sample
---|---|---|---
moment-picker | | Two-way bindable property as formatted datetime string. | Plunker
ng-model | | Two-way bindable property as Moment.js object. | Plunker
locale | "en" | Locale code. 1 | Plunker"L LTS"
format | | Format of the output value and min/max date. 1 | Plunker"decade"
min-view | | Minimum navigable view. | Plunker"minute"
max-view | | Maximum navigable view. | Plunker"year"
start-view | | Initial view when the picker is open. | Plunkerfalse
min-date | | Two-way bindable property representing the minimum selectable date (as String in the same format of the value, or as a Moment.js object). | Plunker
max-date | | Two-way bindable property representing the maximum selectable date (as String in the same format of the value, or as a Moment.js object). | Plunker
start-date | | Two-way bindable property representing the initial date to be shown in picker (as String in the same format of the value, or as a Moment.js object). | Plunker
disable | | Disables the picker if truly. | Plunker"top left"
position | | Sets a fixed position for the picker. Available values are , "top right", "bottom left", "bottom right". | Plunkerfalse
inline | | Views the picker inline. | Plunkertrue
validate | | Forces picker value between the range minDate and maxDate. | Plunkertrue
autoclose | | Closes the picker after selecting a date. | Plunkerfalse
set-on-select | | Updates picker model after selecting a date in each view. | Plunkertrue
is-open | | Open/closes the picker when set to or false. | Plunkerfalse
today | | Highlights the current day. | Plunkerfalse
keyboard | | Allows using the keyboard to navigate the picker. | Plunkertrue
show-header | | Shows the header in the view. | Plunker{ top: undefined, bottom: undefined }
additions | | Template url for custom contents above and below each picker views (inside the dialog). | Plunker
Append your method to your element and define its behavior in the controller.
`html`
Next exhibition is on {{ ctrl.exhibition }}.
`javascript`
ctrl.isSelectable = function (date, type) {
// disable all Sundays in the Month View
return type != 'day' || date.format('dddd') != 'Sunday';
};
Method | Parameters | Description | Sample
---|---|---|---
selectable | date, type | Return true if the given date can be selected in the current view. Please note that this method is called for every date in the view, every time a view is rendered, so be careful, it may affect performances. | Plunker
As for methods, to bind an event you only need to attach the right property to your picker.
`html`
The meeting starts at {{ ctrl.meeting }}.
`javascript`
ctrl.onChange = function (newValue, oldValue) {
$log.log('Meeting changed from ' + oldValue + ' to ' + newValue);
};
Event | Parameters | Description | Sample
---|---|---|---
change | newValue, oldValue | Function fired upon change in picker value. | Plunker
Angular Moment Picker comes out with its own provider, in order to define your own configuration for all the pickers in your app.
`javascript`
angular
.module('myApp', ['moment-picker'])
.config(['momentPickerProvider', function (momentPickerProvider) {
momentPickerProvider.options({
/ ... /
});
}]);
Property | Default | Description
---|---|---
locale | "en" | Locale code. 1"L LTS"
format | | Format of the output value and min/max date. 1"decade"
min-view | | Minimum navigable view."minute"
max-view | | Maximum navigable view."year"
start-view | | Initial view after picker opening."top left"
position | | Sets a fixed position for the picker. Available values are , "top right", "bottom left", "bottom right".false
inline | | Views the picker inline.true
validate | | Forces picker value between the range minDate and maxDate.true
autoclose | | Closes the picker after selecting a date.false
set-on-select | | Updates picker model after selecting a date in each view.false
today | | Highlights the current day.false
keyboard | | Allows using the keyboard to navigate the picker.true
show-header | | Shows the header in the view."←"
left-arrow | | Left arrow string (HTML allowed)."→"
right-arrow | | Right arrow string (HTML allowed).{ top: undefined, bottom: undefined }
additions | | Template url for custom contents above and below each picker views (inside the dialog)."YYYY"
years-format | | Years format in decade view."MMM"
months-format | | Months format in year view."D"
days-format | | Days format in month view."HH:[00]"
hours-format | | Hours format in day view.0
hours-start | | First rendered hour in day view (24h format).23
hours-end | | Last rendered hour in day view (24h format).hour
minutes-format | 2 | Minutes format in view.5
minutes-step | | Step between each visible minute in hour view.0
minutes-start | | First rendered minute in hour view.59
minutes-end | | Last rendered minute in hour view."ss"
seconds-format | | Seconds format in minute view.1
seconds-step | | Step between each visible second in minute view.0
seconds-start | | First rendered second in minute view.59
seconds-end | | Last rendered second in minute view.
1. Locale codes and format tokens are available at http://momentjs.com/.
2. Locale format LT without meridiem part (AM/PM, am/pm).
Try the online Angular Moment Picker Builder:
http://indrimuska.github.io/angular-moment-picker/#builder.
- npm run build: compile sources and generate built files in dist folder.npm run minify
- : generate built files and minified ones.npm run release
- : increase package version and compile the project.npm run test
- : run all tests in the tests` folder.