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?
+1 this has been painful for me too
+1
@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.
+1 Would love, love love to have this feature! In that case (and for others) 1.3 can't come soon enough @Thinkscape, nice !
+1
@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
+1, my project is on hold because of this...
@alexbowen That's hardly an excuse - it's doable even without this feature.
Just ran into this problem - writing code exactly as in the @Thinkscape example above.
+1
+1 :+1: :+1: :+1: :+1:
ng-name plz
+1
+1
+1
+1
+1
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.
+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
])
+1
@Thinkscape thank you for the decorator.