My use case :
I have a multi step form using ui-router like in the plunkr below. I use ng-form to validate information provided by AngularJS, like $valid, $dirty etc.
After each click on the "Next section" button, I send the form data to the server in order to retrieve it, in case the user quits the form before finishing.
If the user submits the first step twice, I ONLY send the edited data (if the $dirty value is true). All of this is not in the plunkr, I chose to show you a simple form, but my form can contain a hundred fields (radio, checkbox, input, select etc.).
The steps to reproduce the issue (plunkr) :
- Fill step 1 and go to next section
- Check xbox radio and return to step 1 by clicking on the number
myMultiStepForm.interests.xbox.$dirty = true
- Come back to step 2
myMultiStepForm.interests.xbox.$dirty = false
Why is $dirty value changed to false? I guess it's because the <ng-form>
is displayed again and all validation data is reset.
Is there a way to avoid this ? Or maybe something other than <ng-form>
to handle validation of subsets of fields ?
This is the plunkr : http://plnkr.co/edit/WclqVgiBvUXlsGdSCcj0?p=preview