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

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.

MarcMouallem avatar May 12 '14 22:05 MarcMouallem

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

grimwinoleader avatar May 12 '14 23:05 grimwinoleader

+1

elnazabo avatar May 13 '14 14:05 elnazabo

+1

mrniko avatar May 15 '14 05:05 mrniko

+1

lucalanca avatar May 16 '14 12:05 lucalanca

+1

Jadaw1n avatar May 16 '14 23:05 Jadaw1n

+1

kinoakter avatar May 19 '14 17:05 kinoakter

+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 }}]"

j0hnsmith avatar May 20 '14 22:05 j0hnsmith

+1

snarknn avatar May 21 '14 16:05 snarknn

+1

amitjagtap avatar Jun 06 '14 04:06 amitjagtap

+1

SamLebarbare avatar Jun 10 '14 20:06 SamLebarbare

+1

timmlk avatar Jun 12 '14 12:06 timmlk

+1

tclausing avatar Jun 13 '14 01:06 tclausing

How long is a fix for this 2 year old issue going to take?

digitalgym avatar Jun 13 '14 02:06 digitalgym

@digitalgym for someone who never helped angular.js, you're pretty rude, you know?

plentz avatar Jun 13 '14 02:06 plentz

@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 avatar Jun 13 '14 03:06 digitalgym

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

fiznool avatar Jun 19 '14 15:06 fiznool

@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

agusl88 avatar Jun 19 '14 21:06 agusl88

+1

touhonoob avatar Jun 20 '14 10:06 touhonoob

+1

ejayimperial avatar Jun 22 '14 16:06 ejayimperial