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?
@sgandotra Soon? The issue was created two years ago.
This issue is pretty much the final straw for me. Any future apps will be on emberjs and our main big one will probably be refactored to emberjs or angulardart if it ever gets stable. Angularjs just can't be trusted, it has so many issues.
there's no reason for that kind of negativity! Anyways, workarounds are readily available and have been linked numerous times in this thread, it's not like applications are really limited here
:unamused:
+1
+1
:+1:
+1 Would be nice to have it "in the box".
+1
+1 to implement some facet of ng-name
until then, to help the community would you be willing to update the "API Reference / ng / directive components in ng / input" documentation to add a note in the "name" property description to reflect that it can not be dynamically populated and possibly leave a link to this issue?
You would be saving those of us who use dynamic form(s) and element(s) in angular a fair amount of time lost to debugging a known feature.
Thank you
I want to resolve this issue one way or another before 1.3 ships. We have workarounds which people use in production, so there is no reason we can't fix this. It's just the "how" and "when" that are problems. @dev-head I suggest you review this issue for the workarounds (I've provided some, as have others) and see if they work well for you --- they are only a few lines of code
@caitp - https://github.com/angular/angular.js/pull/4791 seems to be a pretty straight forward solution for this issue. Is there a reason not to use it?
matias has some concern with it which i haven't heard explained clearly
@caitp @shahata #4791 works, but it doesn't reapply itself incase the name changes again. So think of something like an ngRepeat ... If the $index value changes then so does the input and the errors.
I have a work in progress solution for this at the moment that somewhat works. Lots of broken tests. I can get something out by the start of next week once my schedule opens up.
so, I don't think we actually have to care about the name changing --- however, support for that should be pretty trivial with $observe().
Nobody has ever complained about needing these names to change before, basically
In other words, I think we should start with the simple fix, and then update to support changing control names if people need that in the future (I think the problem with that is really the difficulty with things like radio controls, where you have multiple controls with the same name)
/cc @tbosch / @jeffbcross what do you think about this? "support all the use cases and never ship" vs "support what people have asked for and ship"
well we didn't start with the simple fix... I hope that solves peoples issues <_<
Please try this out and let me know if there are any problems
Is the documentation wrong then at this point? "Since you cannot dynamically generate the name attribute of input elements using interpolation, you have to wrap each set of repeated inputs in an ngForm directive and nest these in an outer form element." Reference: https://code.angularjs.org/1.3.0-rc.4/docs/api/ng/directive/form
yes it is, care to send a PR?