frServerErrors.js 561 Bytes
angular.module('fr.serverErrors', [])

.directive('frServerErrors', ['$compile', function ($compile) {
    return {
        restrict: 'A',
        require: '?ngModel',
        link: function (scope, element, attrs, ngModel) {
            var serverErrors = attrs.frServerErrors.split(',');

            element.on('change', function () {
                angular.forEach(serverErrors, function (error) {
                    scope.$apply(function () {
 						ngModel.$setValidity(error, true);
 					});
                });
            });
        },
    };
}]);