i found what i needed...

It is possible to set manually:
$scope.createProjectForm.$setSubmitted()

and then make the input children $watch for this change:

scope.$watchGroup([
                function(){
                    return ngModelCtrl.$untouched;
                },

                function(){
                    return ngModelCtrl.$valid;
                },

                function(){
                    return ngModelCtrl.$$parentForm.$submitted;
                }

], function(Paramaters){

             // code here

            }

 



On Wednesday, December 9, 2015 at 11:36:13 AM UTC+2, yl2015 wrote:
>
> I have a directive that $watch and validates inputs inside a form based 
> on their $valid and $untouched properties - if the input was "touched" it 
> checks for validation and colors the font and border in red/green 
> accordingly, if the input wasn't "touched" it won't do anything.
>
> I'm using ngBootBox's custom dialog so i don't have the type="submit" kind 
> of button for submitting the form, I'm using the callback function of the 
> "Create" button in order to pass/save the data.
>
> My problem is that when I click the "create" button and the form is not 
> "valid" because some of the fields are empty - my inputs are still 
> "untouched" so the $watch function isn't being called.
>
> I'm trying to avoid iterating the form's inputs with angular's forEach 
> function like this: 
>
>     angular.forEach($scope.form.$error, function (field) {
>         angular.forEach(field, function(errorField){
>             errorField.$setTouched();
>         });
>     })
>
>
> is there a way to do it otherwise? Does the parent form has a property 
> that if changed will influence all inputs and will trigger the $watch 
> function?
>
> i got the relevant code here:
>
>
> http://stackoverflow.com/questions/34164122/how-to-set-all-inputs-as-touched-without-submit-button-angularjs
>
>
> thanks... :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to