1

I have two forms:

<div ui-view="form1">
    <form name=form1> </form>
</div>

<form name=form2> </form>

How can I access validation status of first form (which is in child scope) in second form? For example I need to disable 'submit' button for second form if first form is $invalid.

Thanks

1 Answer 1

1

This should do the trick:

JSFiddle

<form name="form1">
    <input type="text" ng-model="firstname" required />
</form>
<form name="form2">
    <button type="submit" ng-disabled="form1.$invalid">Save</button>
</form>

Please take also a look at the FormController and its properties you can use to check inputs/form statuses (dirty, pristine, valid, etc...).

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for your answer. I updated the question with info about the form1 which is in child scope, created by ui-router. In this case your current answer isn't working.
I don't get the problem if it's a child it inherits the parent scope. Look at this JSFiddle and change it if needed jsfiddle.net/michelem09/a8q89myf
I can't access child scope from parent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.