Saturday 15 February 2014

javascript - Keep $dirty status of form input field when switching views with ui-router -



javascript - Keep $dirty status of form input field when switching views with ui-router -

is there easy way maintain $pristine / $dirty status of input fields within form wrapped around nested view when switching nested view?

my app has next structure:

<div ui-view> <!-- main view - stays active --> <div ng-form="form.product"> content <div ui-view></div> <!-- sub view - changes , holds different parts of form --> <!-- content of inner view (its template) looks this: <input type="text" ng-model="mymodel.someproperty"/> --> </div> </div>

the controller holds form info on outer view controller. when switch tabs (and hence content of inner view), values of inner input elements show right values. can update values, works fine, except 1 thing: validation status beingness reset.

when alter input field, outer form , inner input elements $dirty - when switch inner view , again, outer form still $dirty but inner input element $pristine again, though input elements still hold changed values , outer form still $dirty.

i think input elements $dirty/$pristine status beingness reset when inner view unloaded , loaded again, although values beingness updated model values outer form when come view.

is there easy way maintain $dirty status when switch view without much additional code (like keeping track of changes every singe input element myself)?

javascript angularjs forms validation angular-ui-router

No comments:

Post a Comment