Created
February 23, 2016 19:48
-
-
Save andresmoschini/7f7915726ff7c258c422 to your computer and use it in GitHub Desktop.
This file contains 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
(function () { | |
'use strict'; | |
angular | |
.module('dopplerRelay') | |
.directive('validationErrors', validationErrors); | |
validationErrors.$inject = [ | |
"$compile" | |
]; | |
function validationErrors($compile) { | |
var directive = { | |
restrict: 'A', | |
link: function (scope, element, attrs) { | |
var fieldName = attrs.name; | |
var content = angular.element( | |
'<div class="validation-error" ' | |
+ 'ng-show="form.$submitted || (form.' + fieldName + '.$touched && form.' + fieldName + '.$dirty)">' | |
+ ' <span ng-repeat="(errorKey, error) in form.' + fieldName + '.$error">' | |
+ ' {{"validation_error_" + errorKey | translate}}' | |
+ ' </span>' | |
+ ' </div>'); | |
element.after(content); | |
$compile(content)(scope); | |
} | |
}; | |
return directive; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment