Created
December 29, 2015 23:51
-
-
Save bbrown/65885e956e9f335ea383 to your computer and use it in GitHub Desktop.
Angular directive to validate that one date is greater than another.
This file contains hidden or 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
| 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