You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
When using $removeControl to remove a nested ng-form, the inner form still holds a reference to parentForm, (specifically those 3 methods: $setValidity, $setDirty and $setSubmitted). So, when the validity state of the nested (isolated) form changes, it will also affect the parentForm, even though it was removed.
Suggested Fix
In above mentioned methods, add if(parentForm[form.$name]){/*do*/} before changing parentForm to check if it still holds a reference to the nested form/control
When using
$removeControlto remove a nestedng-form, the inner form still holds a reference to parentForm, (specifically those 3 methods:$setValidity,$setDirtyand$setSubmitted). So, when the validity state of the nested (isolated) form changes, it will also affect the parentForm, even though it was removed.Here is a Demo
http://plnkr.co/edit/uiUjwB?p=preview
Occurences of
parentFormreferenced in nested form/controladdSetValidityMethodFormController.$setDirtyFormController.$setSubmittedSuggested Fix
In above mentioned methods, add
if(parentForm[form.$name]){/*do*/}before changingparentFormto check if it still holds a reference to the nested form/control