UNPKG

landers.angular

Version:

landers.angular

23 lines (21 loc) 732 B
;angular.module('Landers.angular') .directive('dateFormat', ['$filter', function($filter){ return { restrict: 'A', require: 'ngModel', link: function (scope, elm, attrs, ctrl) { function formatter(value) { if (!value) { return ''; } var format = attrs['dateFormat']; return $filter('datetime')(value, scope.format); } function parser() { return ctrl.$modelValue; } ctrl.$formatters.push(formatter); ctrl.$parsers.unshift(parser); } } }]);