angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

dynamic element validation

Open hyusetiawan opened this issue 14 years ago • 235 comments

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?

hyusetiawan avatar Sep 21 '12 22:09 hyusetiawan

@sgandotra Soon? The issue was created two years ago.

yaroslav-ulanovych avatar Aug 18 '14 13:08 yaroslav-ulanovych

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.

robclancy avatar Sep 02 '14 19:09 robclancy

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

caitp avatar Sep 02 '14 19:09 caitp

:unamused:

robclancy avatar Sep 02 '14 19:09 robclancy

+1

mtpultz avatar Sep 03 '14 19:09 mtpultz

+1

dan1d avatar Sep 04 '14 18:09 dan1d

:+1:

graywolf336 avatar Sep 07 '14 06:09 graywolf336

+1 Would be nice to have it "in the box".

wojciechfornal avatar Sep 14 '14 13:09 wojciechfornal

+1

rezorte avatar Sep 15 '14 17:09 rezorte

+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

dev-head avatar Sep 18 '14 00:09 dev-head

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 avatar Sep 18 '14 00:09 caitp

@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?

shahata avatar Sep 18 '14 04:09 shahata

matias has some concern with it which i haven't heard explained clearly

caitp avatar Sep 18 '14 04:09 caitp

@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.

matsko avatar Sep 23 '14 03:09 matsko

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

caitp avatar Sep 23 '14 13:09 caitp

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)

caitp avatar Sep 23 '14 13:09 caitp

/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"

caitp avatar Sep 23 '14 13:09 caitp

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

caitp avatar Sep 23 '14 20:09 caitp

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

DeborahK avatar Oct 31 '14 19:10 DeborahK

yes it is, care to send a PR?

caitp avatar Oct 31 '14 19:10 caitp