json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

how to use form.$valid in controller? #801

Closed orbg closed 7 years ago

orbg commented 7 years ago

Enhancement

I should be able to use form.$valid from within my controller functions. At the moment i can us it from within a submit function as in your examples:

$scope.onSubmit = function(form) {
    // First we broadcast an event so all fields validate themselves
    $scope.$broadcast('schemaFormValidate');

    // Then we check if the form is valid
    if (form.$valid) {
        // ... do whatever you need to do with your data.
    }
};

Actual behaviour

$scope.form.$valid is actually not available in my controller. How to access this?

orbg commented 7 years ago

Sorry, found it. You can use formname.$valid in my case this was not in the scope ..

Anthropic commented 7 years ago

Thank you @orbg for self closing, appreciate your time :)