From 8f989d652f70fd147f66a18411070c7b939e242e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 4 Nov 2013 10:32:23 -0800 Subject: fix(ngModel): deregister from the form on scope not DOM destruction Due to animations, DOM might get destroyed much later than scope and so the element $destroy event might get fired outside of $digest, which causes changes to the validation model go unobserved until the next digest. By deregistering on scope event, the deregistration always happens in $digest and the form validation model changes will be observed. Closes #4226 Closes #4779 --- src/ng/directive/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index cc97411a..1c37167d 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -1222,7 +1222,7 @@ var ngModelDirective = function() { formCtrl.$addControl(modelCtrl); - element.on('$destroy', function() { + scope.$on('$destroy', function() { formCtrl.$removeControl(modelCtrl); }); } -- cgit v1.2.3