Skip to content

Instantly share code, notes, and snippets.

@deyceg
Last active August 29, 2015 14:27
Show Gist options
  • Save deyceg/ff72acb0009d5c1a385b to your computer and use it in GitHub Desktop.
Save deyceg/ff72acb0009d5c1a385b to your computer and use it in GitHub Desktop.
Schema Form Partial Validation
function validateOnCollapse(){
var accordionScope = accordionCtrl.groups[scope.$index];
accordionScope.$watch('isOpen', function(newVal, oldVal) {
if(newVal === false){ //closing
$rootScope.$broadcast('schemaFormValidate', obj);
}
if(accordionForm.$invalid){
accordionScope.isOpen = true;
}
});
}
scope.$on('schemaFormValidate', function(evt, f) {
var match = false;
var form = getForm();
schemaForm.traverseForm(f, function(part){
if(match) return;
match = angular.equals(form.schema, part.schema)
})
if(match){
if (ngModel.$setDirty) {
// Angular 1.3+
ngModel.$setDirty();
validate(ngModel.$modelValue);
} else {
// Angular 1.2
ngModel.$setViewValue(ngModel.$viewValue);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment