This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Bug in angular.FormController when nesting ng-form's #9035
Closed
Description
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.
Here is a Demo
http://plnkr.co/edit/uiUjwB?p=preview
Occurences of parentForm
referenced in nested form/control
addSetValidityMethod
FormController.$setDirty
FormController.$setSubmitted
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