I have a subform that is shared among multiple views in my app. In one view, this subform is displayed alone with a back/continue button at the bottom that leads the user to the next subform. In another view, the subform is displayed on the same page as other subforms (basically one long form).
Since the html of the subform is 100% identical in both views, I separated it into a partial and am using ng-include
to render it. In the view that displays only the subform with the back/continue buttons, I render the back/continue buttons within the parent's HTML.
Visually, everything works fine, and I'm able to access all of the data entered in the form (user.email, user.password, user.etc...
).
The problem is that I'm enabling/disabling the "continue" button based on whether or not the user has completed the form correctly, and this does not work in the "subform-only" variation because the parent scope doesn't seem to be able to access the form's status. If I stick the buttons in the partial, it works, but I don't want to do that because the buttons don't belong there in every instance that this partial is being used.
Notice in my example that the submit button within the red border is disabled until something is typed in the box and the "Form Invalid?" value updates, while the button within the blue border is always enabled and the "Form Invalid?" value is blank.
How can I access the value of myForm.$invalid
from the parent scope?