I'm facing an issue with dynamic input validation. Here's the sample at 
plunker:
http://plnkr.co/edit/WuwYATNYk6SAyRluyiTb?p=info

The structure of application is following:
* Controller has list of objects 
* Each object has related directive, which is displayed when object is 
selected (say directive-for-object1, directive-for-object2, 
directive-for-object3)
* View contains is a form and ng-form that wrap directives for object
* object directives contain 'logic' to edit the object - inputs with 
validation attributes
* when object is selected, corresponding directive is compiled and added, 
effectively adding/removing inputs to/from contained form;

As a result when i switch between objects, validation errors are 
'accumulated' in the summary part

I check source code of an angular and can see that ng-model subscribes to 
the current scopes destroy event. However in my case inputs are removed 
without destroying scope parent scope.

Second issue is within NgModelController -  at the buttom of the object 
definition it subscribes to $scope.$watch and this subscription is never 
released. So again even though input is removed from the form validation 
keeps firing for the input. If you'll debug code of NgModelController 
you'll see that validation fired for inputs with undefined names because 
inputs are actually removed.

Doesn't it make sense to track lifetime of an input and release validation, 
formatters etc as input get destroyed?

There is a workaround however - if 'object directives' use isolated scope, 
then validation errors do not proliferate, because scope is destroyed when 
object switches.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to