Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@robhurring
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robhurring/0cb8dead9ccce26c1570 to your computer and use it in GitHub Desktop.
Save robhurring/0cb8dead9ccce26c1570 to your computer and use it in GitHub Desktop.
angular pikaday
/* global angular, Ladda */
(function(module, $) {
'use strict';
module.directive('datepicker', function() {
return {
link: function postLink(scope, element, attrs) {
var today = new Date();
var minYear = 1900;
var maxYear = today.getFullYear();
var defaultDate = new Date();
defaultDate.setFullYear(defaultDate.getFullYear() - 17);
$(element).pikaday({
format: 'MM/DD/YYYY',
yearRange: [minYear, maxYear],
maxDate: today,
defaultDate: defaultDate
});
}
};
});
})(angular.module('MyModule'), jQuery);
<input
name="date_of_birth"
ng-model="form.date_of_birth"
type="text"
placeholder="__/__/____"
datepicker
required>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment