Skip to content

Instantly share code, notes, and snippets.

@bbrown
Created December 29, 2015 23:51
Show Gist options
  • Select an option

  • Save bbrown/65885e956e9f335ea383 to your computer and use it in GitHub Desktop.

Select an option

Save bbrown/65885e956e9f335ea383 to your computer and use it in GitHub Desktop.
Angular directive to validate that one date is greater than another.
angular.module("app").directive("validateDateGreaterThan", function()
{
return {
require: "ngModel",
scope:
{
firstDate: "=validateDateGreaterThan"
},
link: function(scope, element, attrs, ngModel)
{
ngModel.$validators.dateGreaterThan = function(modelValue)
{
return (new Date(modelValue) > new Date(scope.firstDate));
};
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment