Last active
August 29, 2015 14:14
-
-
Save robhurring/0cb8dead9ccce26c1570 to your computer and use it in GitHub Desktop.
angular pikaday
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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