1angular.module('app.common.directives').directive('hasError', function() {
2  return {
3    scope: {hasError: '='},
4    require: 'ngModel',
5    link: function(scope, elm, attrs, ngModel) {
6      scope.$watch('hasError', function(value) {
7        ngModel.$setValidity('hasError', value ? false : true);
8      });
9    }
10  };
11});
12