dynamic element validation
I have a problem with validating inputs that are generated dynamically. Here is the fiddle that shows the problem: http://jsfiddle.net/flsilva/8JzDb/17/
this is taken from: https://groups.google.com/forum/?fromgroups=#!topic/angular/qLeUWZVuQMI
the name is generated fine but it's not bound to the form scope. Because I can name it correctly but the form is not bound, it seems that this behavior is inconsistent.
Thoughts?
The nested ng-form solution is awesome cause it solves the problem in an incredibly AngularJS way. Create a new scope! You keep the name the same and have a different scope for each repeat. That's what the ng-form is doing. I don't see this as a bug, but rather the AngularJS way. Dynamic name attribute is much messier.
When dealing with forms and (sub forms via ng-form) adding additional ng-forms around inputs in an ng-repeat just to get dynamic naming thus adding another scope, seems to make the management of form validation data just that much harder. It feels like a work around. That said I am using ng-forms to implement encapsulated subforms but I choose what inputs are grouped and related within an ng-form and don't have to let a 1,000 ng-forms bloom to uniquely name input elements so I can process form validation data for each. I too have a directive that lets me do this but would rather have this in the core. That said I would understand if the AngularJS team did not want to support interpolated names within an ng-repeat due to code creep or performance issues.
+1 please
+1
+1
+1
+1
+1
+1 I'd also like to see names update so that names stay in sync when dynamically added form fields are removed eg name="myField[{{ $index }}]"
+1
+1
+1
+1
+1
How long is a fix for this 2 year old issue going to take?
@digitalgym for someone who never helped angular.js, you're pretty rude, you know?
@plentz for an issue with 135 comments and running for nearly 2 years and receiving +1's everyday, what's a reasonable response time in your opinion?
@digitalgym please see @Thinkscape's fiddle for a great workaround which fixes this problem. Just include it in your project and add a dependency to it in your app.
@digitalgym this is more like a new feature than a bug. As @fiznool said, check the fiddle with the workaround, is just copy+paste a code snippet
+1
+1