ng-required backing fields

361 views
Skip to first unread message

avina...@gmail.com

unread,
Sep 3, 2012, 6:01:22 AM9/3/12
to ang...@googlegroups.com
Hello, 

I find the ng-required api extremely useful and flexible in how it works. It works great in a typical ng use case where data is bound to fields defined in the controller. However, it does not work(fully ??.... styling etc is broken... but some amount of it seems to work) when I try to apply the ng-required attribute on a form element that is not bound to a view model/controller field. This is perfectly rational from a ng point of view. 

Is it possible to get this working with non ng controller backed fields ? It will be super useful. 

Thanks, 
/A

Peter Bacon Darwin

unread,
Sep 3, 2012, 9:17:06 AM9/3/12
to ang...@googlegroups.com
The form validation relies upon ngModelController which is triggered by the use of ngModel.  It would be possible to write your own required directive that could look for a FormController on a containing form element and set the $valid field on that directly.  It might be easier, though, for you to just have a dummy ng-model attribute on your form element.
Pete

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Reply all
Reply to author
Forward
0 new messages