rnaffer
6/6/2016 - 4:35 PM

ui-select Required Directive

ui-select Required Directive

app.directive('uiSelectRequired', function() {
  return {
    require: 'ngModel',
    link: function(scope, elm, attrs, ctrl) {
      ctrl.$validators.uiSelectRequired = function(modelValue, viewValue) {
          for(var prop in modelValue) {
              if(modelValue.hasOwnProperty(prop))
                  return true;
          }

          return false && JSON.stringify(modelValue) !== JSON.stringify({});
      };
    }
  };
});