From: Tim Otten Date: Sat, 24 Jan 2015 06:27:05 +0000 (-0800) Subject: CRM-15856 - crmUi - Add generic, field-independent validator (crmUiValidate). X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3afb86ef3703af3a1280cebeb11da0b2d94335f0;p=civicrm-core.git CRM-15856 - crmUi - Add generic, field-independent validator (crmUiValidate). --- diff --git a/js/angular-crm-ui.js b/js/angular-crm-ui.js index 1d18f714c2..44b19bdb28 100644 --- a/js/angular-crm-ui.js +++ b/js/angular-crm-ui.js @@ -458,6 +458,22 @@ }; }) + // example: + // example: + // Generic, field-independent validator. + .directive('crmUiValidate', function() { + return { + restrict: 'EA', + require: 'ngModel', + link: function(scope, element, attrs, ngModel) { + var validationKey = attrs.crmUiValidateName ? attrs.crmUiValidateName : 'crmUiValidate'; + scope.$watch(attrs.crmUiValidate, function(newValue){ + ngModel.$setValidity(validationKey, !!newValue); + }); + } + }; + }) + // like ng-show, but hides/displays elements using "visibility" which maintains positioning // example
...content...
.directive('crmUiVisible', function($parse) {