Blame view

resources/js/common/directives/frServerErrors.js 561 Bytes
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  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);
   					});
                  });
              });
          },
      };
  }]);