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

+1 this has been painful for me too

tednaleid avatar Jan 31 '14 02:01 tednaleid

+1

gigablox avatar Jan 31 '14 16:01 gigablox

@caitp thank you!

Would you like to check the availability of 'name' attribute before 'attrs.$set('name', $interpolate(attrs.name || '')(scope));'?

In our scenario, the availability of name is important in another piece of code. $interpolate attrs.name only when it exists makes more sense here.

MrCoder avatar Feb 03 '14 05:02 MrCoder

+1 Would love, love love to have this feature! In that case (and for others) 1.3 can't come soon enough @Thinkscape, nice !

bramslob avatar Feb 06 '14 16:02 bramslob

+1

hnordt avatar Feb 12 '14 13:02 hnordt

@caitp nice use of a decorator for the form. I did the same for ngFormDirective and can now use dynamically generated sub-form names to determine which of the sub-forms is invalid (for user hints). #oweyouabeer

arimus avatar Feb 13 '14 02:02 arimus

+1, my project is on hold because of this...

alexbowen avatar Feb 13 '14 16:02 alexbowen

@alexbowen That's hardly an excuse - it's doable even without this feature.

kirkbushell avatar Feb 13 '14 17:02 kirkbushell

Just ran into this problem - writing code exactly as in the @Thinkscape example above.

michelemottini avatar Feb 13 '14 20:02 michelemottini

+1

Baltazore avatar Feb 17 '14 13:02 Baltazore

+1 :+1: :+1: :+1: :+1:

rick-audax avatar Feb 23 '14 22:02 rick-audax

ng-name plz

rick-audax avatar Feb 23 '14 22:02 rick-audax

+1

aravindanr avatar Feb 24 '14 00:02 aravindanr

+1

mendelk avatar Feb 24 '14 16:02 mendelk

+1

michalkvasnicak avatar Feb 27 '14 14:02 michalkvasnicak

+1

grimwinoleader avatar Mar 02 '14 05:03 grimwinoleader

+1

mlingner avatar Mar 05 '14 21:03 mlingner

Hang tight for another day, because the AngularDart example as a bit of a different approach to handling this and I would like to get everyone to consider the approach before we move forward on this. I'll post a link here to the HTML code tomorrow.

matsko avatar Mar 05 '14 21:03 matsko

+1. @matsko Do you have the link?

Edit: Tried the above decorator and it worked like a charm. Thanks a lot, @Thinkscape.

Here's the decorator in coffeescript, if it pleases anyone. (This is just the part allowing interpolated form name values)

.config(['$provide', ($provide)->
  $provide.decorator 'formDirective', ($delegate)->
    form = $delegate[0]
    controller = form.controller

    form.controller = ['$scope', '$element', '$attrs', '$injector', ($scope, $element, $attrs, $injector)->
      $interpolate = $injector.get('$interpolate')
      $attrs.$set('name', $interpolate($attrs.name || $attrs.ngForm || '')($scope))
      $injector.invoke(controller, this, {
        '$scope' : $scope
        '$element': $element
        '$attrs' : $attrs
      })
    ]
    return $delegate
])

aaronleesmith avatar Mar 13 '14 18:03 aaronleesmith

+1

@Thinkscape thank you for the decorator.

kmlx avatar Mar 18 '14 21:03 kmlx