Skip to content

Instantly share code, notes, and snippets.

@fernandofleury
Last active August 29, 2015 14:02
Show Gist options
  • Save fernandofleury/ddb6b97d911c3e8634c0 to your computer and use it in GitHub Desktop.
Save fernandofleury/ddb6b97d911c3e8634c0 to your computer and use it in GitHub Desktop.
ng-datepicker.js
(function() {
'use strict';
module.exports = ['$filter', function($filter){
return {
restrict: 'A',
link: function(scope, elem, attr) {
var options = {
field: elem[0]
};
if(attr.ngDatePicker) {
angular.extend(options, scope[attr.ngDatePicker]);
}
var picker = new Pikaday(options);
elem.on('change', function(){
elem.val($filter('date')(elem.val(), 'dd/MM/yyyy'));
});
}
};
}];
})();
$scope.pickerOptions = {
maxDate: new Date()
};
<input class="input date-input" name="date" type="text" placeholder="Data Início" ng-model="filterInit" ng-date-picker="pickerOptions">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment