app .directive('ngModelAsDate', function () { return { restrict: 'A', require: '?ngModel', link: function (scope, element, attrs, ngModel) { ngModel.$formatters.push(function (modelValue) { if (angular.isString(modelValue)) { return new Date(modelValue); } return modelValue; }); } }; });